Page 1 of 1
How to determine the OS language
Posted: Wed Dec 28, 2022 7:03 pm
by AZJIO
How to determine the OS language.
I found
this code but it doesn't work for me.
Code: Select all
Procedure GetLocale()
! var localeos = Locale.getDefault().getLanguage();
; ! return (localeos);
! return (lang.contentEquals("ru"));
EndProcedure
Debug GetLocale()
although I have only tried it on the browser, not on the phone.
Re: How to determine the OS language
Posted: Sat Dec 31, 2022 5:05 am
by plouf
the closest and accurate enough you can et is browser languange
Code: Select all
!var v_browserfirstlanguange = navigator.language;
!var v_browseralllanguanges = navigator.languages;
Debug BrowserFirstLanguange
Debug BrowserAllLanguanges
Re: How to determine the OS language
Posted: Sun Jan 01, 2023 6:25 am
by AZJIO
Thanks, I made some interesting examples
Code: Select all
EnableExplicit
Global NewList MonthL.s()
Global lang0$, lang$
Global i, weekday$
Global Dim Lng.s(3)
Lng(1) = ": loading error"
lang$ = "en"
!var v_lang0$ = navigator.language;
If lang0$ = "ru-RU"
Lng(1) = ": ошибка загрузки"
lang$ = "ru"
EndIf
! for (var i = 0; i < 12; i++) {
If AddElement(MonthL())
! t_MonthL.current._s = i + 1 + '\t' + new Date(0,i).toLocaleString(v_lang$, { month: 'long' });
EndIf
! }
; For i = #txtLast To #txtLast + 6
For i = 1 To 7
! v_weekday$ = new Date(0, 9, v_i).toLocaleString(v_lang$, { weekday: 'short' });
Debug weekday$
Next
ForEach MonthL()
Debug MonthL()
Next