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
This commit is contained in:
Daniel García Moreno 2018-05-18 10:34:17 +02:00 committed by Eisha CHEN-YEN-SU
parent e312370817
commit 1905a2b5d1
7 changed files with 41 additions and 3 deletions

View file

@ -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

View file

@ -1,4 +1,8 @@
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();
}

View file

@ -1,3 +1,4 @@
# please keep this list sorted alphabetically
#
fr
es

View file

@ -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");

View file

@ -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"));

View file

@ -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

View file

@ -1,6 +1,6 @@
#!/bin/sh
export CARGO_HOME=$1/target/cargo-home
export FRACTAL_LOCALEDIR="$3"
if [[ $DEBUG = true ]]
then