EAPI int evas_string_char_len_get(const char *str) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
/**
+ * Reinitialize language from the environment.
+ *
+ * The locale can change while a process is running. This call tells evas to
+ * reload the locale from the environment like it does on start.
+ * @ingroup Evas_Utils
+ * @since 1.18
+ */
+EAPI void evas_language_reinit(void);
+
+/**
* @defgroup Evas_Keys Key Input Functions
*
* Functions which feed key events to the canvas.
#define EXPLICIT_SCRIPT(script) \
(((script) != EVAS_SCRIPT_UNKNOWN) && ((script) > EVAS_SCRIPT_INHERITED))
+static char lang[6]; /* FIXME: Maximum length I know about */
+static char lang_full[32];
+
static Evas_Script_Type
_evas_common_language_char_script_search(Eina_Unicode unicode)
{
const char *
evas_common_language_from_locale_get(void)
{
- static char lang[6]; /* FIXME: Maximum length I know about */
if (*lang) return lang;
const char *locale;
const char *
evas_common_language_from_locale_full_get(void)
{
- static char lang[32];
- if (*lang) return lang;
+ if (*lang_full) return lang_full;
const char *locale;
locale = setlocale(LC_MESSAGES, NULL);
if ((c == '.') || (c == '@') || (c == ' ')) /* Looks like en_US.UTF8 or de_DE@euro or aa_ER UTF-8*/
break;
}
- strncpy(lang, locale, i);
- lang[i] = '\0';
- return lang;
+ strncpy(lang_full, locale, i);
+ lang_full[i] = '\0';
+ return lang_full;
}
return "";
}
+void
+evas_common_language_reinit(void)
+{
+ *lang = *lang_full = '\0';
+}
+
/*
* @}
*/
START_TEST(evas_textblock_hyphenation)
{
START_TB_TEST();
+ Evas_Coord w, fw;
+
+ const char *buf = "Automati-";
+ evas_object_textblock_text_markup_set(tb, buf);
+ evas_object_textblock_size_formatted_get(tb, &w, NULL);
+ evas_object_resize(tb, w, 100);
+
+ setlocale(LC_MESSAGES, "en_US.UTF-8");
+ /* Language should be reinitialized after calling setlocale(). */
+ evas_language_reinit();
+
+ buf = "Automatically";
+ evas_object_textblock_text_markup_set(tb, buf);
+ evas_textblock_cursor_format_prepend(cur, "<wrap=hyphenation>");
+ evas_object_textblock_size_formatted_get(tb, &fw, NULL);
+ ck_assert_int_eq(w, fw);
+
+ /* Restore locale */
+ setlocale(LC_MESSAGES, "C");
+ evas_language_reinit();
/* SHY-HYPHEN (­) */
/* Note: placing ­ in a ligature is errornuos, so for the sake
* of this test, it was removed from the "officia" word */
- const char *buf =
+ buf =
"Lorem ipsum dolor sit amet, cons­ectetur adipisicing elit,"
" sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
" Ut enim ad minim veniam, quis nostrud exer­citation ullamco"
evas_object_textblock_text_markup_set(tb, buf);
/* Dictionary + locale fallback (en_US) */
- setlocale(LC_MESSAGES, "en_US.UTF8");
+ setlocale(LC_MESSAGES, "en_US.UTF-8");
+ evas_language_reinit();
/* Mixture of Dictionary with SHY-HYPHEN */
_hyphenation_width_stress(tb, cur);