diff options
| author | Samantaz Fox <coding@samantaz.fr> | 2023-04-18 00:04:49 +0200 |
|---|---|---|
| committer | Samantaz Fox <coding@samantaz.fr> | 2023-07-06 00:23:22 +0200 |
| commit | 0ba22ef391a7b350d139dfd256aa20a7e1f812ed (patch) | |
| tree | 4d5f4709d1b7a4c864fbaf2d6489ec75ae3d4979 /src | |
| parent | 507bed6313b49564e53b69a5c9b4d072d1e05e4b (diff) | |
| download | invidious-0ba22ef391a7b350d139dfd256aa20a7e1f812ed.tar.gz invidious-0ba22ef391a7b350d139dfd256aa20a7e1f812ed.tar.bz2 invidious-0ba22ef391a7b350d139dfd256aa20a7e1f812ed.zip | |
I18n: Add a function to determine if a given locale is RTL
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious/helpers/i18n.cr | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/invidious/helpers/i18n.cr b/src/invidious/helpers/i18n.cr index a9ed1f64..76e477a4 100644 --- a/src/invidious/helpers/i18n.cr +++ b/src/invidious/helpers/i18n.cr @@ -165,3 +165,12 @@ def translate_bool(locale : String?, translation : Bool) return translate(locale, "No") end end + +def locale_is_rtl?(locale : String?) + # Fallback to en-US + return false if locale.nil? + + # Arabic, Persian, Hebrew + # See https://en.wikipedia.org/wiki/Right-to-left_script#List_of_RTL_scripts + return {"ar", "fa", "he"}.includes? locale +end |
