small-tech / watson

Watson is a best-practices application template for elementary OS 6 (Odin).
GNU General Public License v3.0
46 stars 3 forks source link

Locale? #2

Closed aral closed 2 years ago

aral commented 3 years ago

In the core apps that ship with elementary OS, the Application constructor manually sets the locale and binds to the gettext package e.g. in Calculator:

Intl.setlocale (LocaleCategory.ALL, "");
GLib.Intl.bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
GLib.Intl.bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
GLib.Intl.textdomain (GETTEXT_PACKAGE);

The constants used come from the configuration file (Config.vala.in):

public const string GETTEXT_PACKAGE = @GETTEXT_PACKAGE@;
public const string LOCALEDIR = @LOCALEDIR@;

And the actual values are substituted in meson.build:

config_data = configuration_data()
config_data.set_quoted('LOCALEDIR', get_option('prefix') / get_option('localedir'))
config_data.set_quoted('GETTEXT_PACKAGE', meson.project_name())
config_file = configure_file(
    input: 'src/Config.vala.in',
    output: '@BASENAME@',
    configuration: config_data
)

However, none of this is shown in the Translations section of the elementary OS developer documentation.

Can someone with better knowledge of all this than me please answer:

Thanks!

aral commented 2 years ago

Now tracking in #16.