mirror of
https://github.com/BlossomiShymae/clean-cuts.git
synced 2025-12-06 10:10:47 +01:00
Add i18n support for data
This commit is contained in:
54
composables/useLocale.ts
Normal file
54
composables/useLocale.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
|
||||
const locales = {
|
||||
"ar_ae": "Arabic (United Arab Emirates)",
|
||||
"cs_cz": "Czech (Czech Republic)",
|
||||
"de_de": "German (Germany)",
|
||||
"default": "English (United States)",
|
||||
"el_gr": "Greek (Greece)",
|
||||
"en_au": "English (Australia)",
|
||||
"en_gb": "English (United Kingdom)",
|
||||
"en_ph": "English (Philippines)",
|
||||
"en_sg": "English (Singapore)",
|
||||
"es_ar": "Spanish (Argentina)",
|
||||
"es_es": "Spanish (Spain)",
|
||||
"es_mx": "Spanish (Mexico)",
|
||||
"fr_fr": "French (France)",
|
||||
"hu_hu": "Hungarian (Hungary)",
|
||||
"it_it": "Italian (Italy)",
|
||||
"ja_jp": "Japanese (Japan)",
|
||||
"ko_kr": "Korean (South Korea)",
|
||||
"pl_pl": "Polish (Poland)",
|
||||
"pt_br": "Portuguese (Brazil)",
|
||||
"ro_ro": "Romanian (Romania)",
|
||||
"ru_ru": "Russian (Russia)",
|
||||
"th_th": "Thai (Thailand)",
|
||||
"tr_tr": "Turkish (Turkey)",
|
||||
"vi_vn": "Vietnamese (Vietnam)",
|
||||
"zh_cn": "Chinese",
|
||||
"zh_my": "Chinese (Malaysia)",
|
||||
"zh_tw": "Chinese (Taiwan)"
|
||||
};
|
||||
|
||||
const currentLocale = ref(getLocale());
|
||||
|
||||
function getLocale(): string {
|
||||
var currentLocale: string | null = localStorage.getItem("locale");
|
||||
if (currentLocale == null) {
|
||||
currentLocale = "default";
|
||||
setLocale(currentLocale);
|
||||
}
|
||||
return currentLocale;
|
||||
}
|
||||
|
||||
function setLocale(locale: string): void {
|
||||
localStorage.setItem("locale", locale);
|
||||
currentLocale.value = locale;
|
||||
}
|
||||
|
||||
export default function useLocale() {
|
||||
return {
|
||||
locales,
|
||||
currentLocale,
|
||||
setLocale
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user