Commit 1905a2b5 authored by Daniel García Moreno's avatar Daniel García Moreno Committed by Eisha Chen-yen-su

i18n: bindtextdomain not hardcoded

I've added the locales path to the globals so we can now in the compile
time what directory is the translation to use in bindtextdomain

Closes https://gitlab.gnome.org/World/fractal/issues/89
parent e3123708
......@@ -34,6 +34,23 @@ ninja -C _build
sudo ninja -C _build install
```
### Translations
If you want to add a new language you should update the file
`fractal-gtk/po/LINUGAS` and add the new lang to the list.
To generate .pot files you should run:
```
ninja -C _build fractal-pot
```
To generate .po files you should run:
```
ninja -C _build fractal-update-po
```
### Password Storage
Fractal uses Secret Service to store the password so you should have
......
use std::process::Command;
use std::env;
use std::fs::File;
use std::path::Path;
use std::io::Write;
fn main() {
// Compile Gresource
......@@ -7,4 +11,17 @@ fn main() {
.current_dir("res")
.status()
.unwrap();
// Generating build globals
let out_dir = env::var("OUT_DIR").unwrap();
let localedir = env::var("FRACTAL_LOCALEDIR").unwrap();
let dest_path = Path::new(&out_dir).join("build_globals.rs");
let mut f = File::create(&dest_path).unwrap();
let globals = format!("
pub static LOCALEDIR: &'static str = \"{}\";
",
localedir);
f.write_all(&globals.into_bytes()[..]).unwrap();
}
# please keep this list sorted alphabetically
#
fr
es
......@@ -83,7 +83,7 @@ impl App {
// Set up the textdomain for gettext
setlocale(LocaleCategory::LcAll, "");
bindtextdomain("fractal", "./fractal-gtk/po");
bindtextdomain("fractal", globals::LOCALEDIR);
textdomain("fractal");
......
......@@ -5,3 +5,5 @@ pub static USERLIST_ICON_SIZE: i32 = 30;
pub static MINUTES_TO_SPLIT_MSGS: i64 = 30;
pub static APP_ID: &'static str = "org.gnome.Fractal";
include!(concat!(env!("OUT_DIR"), "/build_globals.rs"));
......@@ -12,6 +12,7 @@ fractal_version_micro = version_array[2].to_int()
fractal_prefix = get_option('prefix')
fractal_bindir = join_paths(fractal_prefix, get_option('bindir'))
fractal_localedir = join_paths(fractal_prefix, get_option('localedir'))
datadir = get_option('datadir')
icondir = join_paths(datadir, 'icons')
......@@ -37,7 +38,7 @@ cargo_release = custom_target('cargo-build',
output: ['fractal'],
install: true,
install_dir: fractal_bindir,
command: [cargo_script, '@CURRENT_SOURCE_DIR@', '@OUTPUT@'])
command: [cargo_script, '@CURRENT_SOURCE_DIR@', '@OUTPUT@', fractal_localedir])
run_target('release', command: ['scripts/release.sh',
meson.project_name() + '-' + fractal_version
......
#!/bin/sh
export CARGO_HOME=$1/target/cargo-home
export FRACTAL_LOCALEDIR="$3"
if [[ $DEBUG = true ]]
then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment