- added @adonisjs/mail
Some checks failed
CI Pipeline / japa-tests (push) Failing after 1m2s

- mail_settings_controller for setting smtp settings
- added view ror rjecting dataset for editor
- added new model AppConfig for stroing appwide config values
- better validate_chesum.ts command with process chunking
- added vue3 apps 'BasicSettings' like email, profile settings
- started with 2 multilingual capabilities
- npm updates
This commit is contained in:
Kaimbacher 2024-09-16 17:59:46 +02:00
parent 010bead723
commit b06ccae603
67 changed files with 7820 additions and 1463 deletions

View file

@ -0,0 +1,83 @@
/**
* Returns the user's locale
*/
export function getLocale(): string {
return document.documentElement.dataset.locale || 'en'
}
/**
* Returns user's locale in canonical form
* E.g. `en-US` instead of `en_US`
*/
export function getCanonicalLocale(): string {
return getLocale().replace(/_/g, '-')
}
/**
* Returns the user's language
*/
export function getLanguage(): string {
return document.documentElement.lang || 'en'
}
/**
* Check whether the current, or a given, language is read right-to-left
*
* @param language Language code to check, defaults to current language
*/
export function isRTL(language?: string): boolean {
const languageCode = language || getLanguage()
// Source: https://meta.wikimedia.org/wiki/Template:List_of_language_names_ordered_by_code
const rtlLanguages = [
/* eslint-disable no-multi-spaces */
'ae', // Avestan
'ar', // 'العربية', Arabic
'arc', // Aramaic
'arz', // 'مصرى', Egyptian
'bcc', // 'بلوچی مکرانی', Southern Balochi
'bqi', // 'بختياري', Bakthiari
'ckb', // 'Soranî / کوردی', Sorani
'dv', // Dhivehi
'fa', // 'فارسی', Persian
'glk', // 'گیلکی', Gilaki
'ha', // 'هَوُسَ', Hausa
'he', // 'עברית', Hebrew
'khw', // 'کھوار', Khowar
'ks', // 'कॉशुर / کٲشُر', Kashmiri
'ku', // 'Kurdî / كوردی', Kurdish
'mzn', // 'مازِرونی', Mazanderani
'nqo', // 'ߒߞߏ', NKo
'pnb', // 'پنجابی', Western Punjabi
'ps', // 'پښتو', Pashto,
'sd', // 'سنڌي', Sindhi
'ug', // 'Uyghurche / ئۇيغۇرچە', Uyghur
'ur', // 'اردو', Urdu
'uzs', // 'اوزبیکی', Uzbek Afghan
'yi', // 'ייִדיש', Yiddish
/* eslint-enable no-multi-spaces */
]
// special case for Uzbek Afghan
if ((language || getCanonicalLocale()).startsWith('uz-AF')) {
return true
}
return rtlLanguages.includes(languageCode)
}
export function getBrowserLocale(options?: { languageCodeOnly: boolean }): string {
const navigatorLocale = navigator.languages !== undefined
? navigator.languages[0]
: navigator.language;
if (!navigatorLocale) {
return 'en'; // Fallback to 'en' if no locale is detected
}
const locale = options?.languageCodeOnly
? navigatorLocale.trim().split(/-|_/)[0]
: navigatorLocale.trim();
return locale;
}