doc: Clarify format of locale identifiers in extra-languages key

Also update the tests to use the same format, and make sure to include
coverage of all forms of locale (language-only, with locale, with
codeset, and with modifier).

Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
Philip Withnall
2019-10-24 10:30:16 +01:00
parent 62cb538440
commit d5a1170820
2 changed files with 18 additions and 13 deletions

View File

@@ -70,8 +70,10 @@
<listitem><para>
This key is used when languages is not set, and it defines extra locale
extensions on top of the system configured languages. The value is a
semicolon-separated list of two-letter language codes or locale identifiers
(eg. en;en_DK;az_Latn_AZ).
semicolon-separated list of locale identifiers
(language, optional locale, optional codeset, optional modifier) as documented by
<citerefentry><refentrytitle>setlocale</refentrytitle><manvolnum>3</manvolnum></citerefentry>
(for example, <literal>en;en_DK;zh_HK.big5hkscs;uz_UZ.utf8@cyrillic</literal>).
</para></listitem>
</varlistentry>
</variablelist>

View File

@@ -291,27 +291,30 @@ test_languages_config (void)
g_assert_cmpstr (value[0], ==, "en");
g_assert_null (value[1]);
res = flatpak_installation_set_config_sync (inst, "extra-languages", "pt_BR;az_Latn_AZ;es", NULL, &error);
res = flatpak_installation_set_config_sync (inst, "extra-languages", "pt_BR;uz_UZ.utf8@cyrillic;es;zh_HK.big5hkscs;uz_UZ@cyrillic", NULL, &error);
g_assert_no_error (error);
g_assert_true (res);
value = flatpak_installation_get_default_languages (inst, &error);
g_assert_no_error (error);
g_assert_cmpstr (value[0], ==, "az");
g_assert_cmpstr (value[1], ==, "en");
g_assert_cmpstr (value[2], ==, "es");
g_assert_cmpstr (value[3], ==, "pt");
g_assert_null (value[4]);
g_assert_cmpstr (value[0], ==, "en");
g_assert_cmpstr (value[1], ==, "es");
g_assert_cmpstr (value[2], ==, "pt");
g_assert_cmpstr (value[3], ==, "uz");
g_assert_cmpstr (value[4], ==, "zh");
g_assert_null (value[5]);
g_clear_pointer (&value, g_strfreev);
value = flatpak_installation_get_default_locales (inst, &error);
g_assert_no_error (error);
g_assert_cmpstr (value[0], ==, "az_Latn_AZ");
g_assert_cmpstr (value[1], ==, "en");
g_assert_cmpstr (value[2], ==, "es");
g_assert_cmpstr (value[3], ==, "pt_BR");
g_assert_null (value[4]);
g_assert_cmpstr (value[0], ==, "en");
g_assert_cmpstr (value[1], ==, "es");
g_assert_cmpstr (value[2], ==, "pt_BR");
g_assert_cmpstr (value[3], ==, "uz_UZ.utf8@cyrillic");
g_assert_cmpstr (value[4], ==, "uz_UZ@cyrillic");
g_assert_cmpstr (value[5], ==, "zh_HK.big5hkscs");
g_assert_null (value[6]);
g_clear_pointer (&value, g_strfreev);