Hi, I am trying to access the device language through systemLanguage but I get a constant error that the symbol cannot find. Any ideas??
Hi, I am trying to access the device language through systemLanguage but I get a constant error that the symbol cannot find. Any ideas??
As jim_m_58 pointed out, the device you're running on (or simulating) needs to have ConnectIQ SDK 3.1.0 support. You can do this check to avoid the symbol not found error:
var deviceSettings = System…
for me, like Travis.ConnectIQ said, I can think of only one of my apps where I use this - requesting data from a website in a specific language.
Are you just looking to localize your app? If so, maybe…
Thanks.
Are you trying it with a target with CIQ 3.1.x? Do you have 3.1.x set as a target SDK in the run config?
As jim_m_58 pointed out, the device you're running on (or simulating) needs to have ConnectIQ SDK 3.1.0 support. You can do this check to avoid the symbol not found error:
var deviceSettings = System.getDeviceSettings();
if (deviceSettings has :systemLanguage) {
// it is safe to access the language
System.println(deviceSettings.systemLanguage);
}
If you need to support devices that don't have 3.1.0 support, there has always been a way to do this using string resources. If you create a string resource for each language, then that string will be set to the appropriate value at runtime. This batch file will create language resource files for you. Just run it from the project root:
@echo off
setlocal
set LANGUAGE_LIST=ara ^
bul ^
ces ^
dan ^
deu ^
dut ^
eng ^
est ^
fin ^
fre ^
gre ^
heb ^
hrv ^
hun ^
ind ^
ita ^
jpn ^
kor ^
lav ^
lit ^
nob ^
pol ^
por ^
ron ^
rus ^
slo ^
slv ^
spa ^
swe ^
tha ^
tur ^
ukr ^
vie ^
zhs ^
zht ^
zsm
for %%i in (%LANGUAGE_LIST%) do (
call :create_language_resource %%i resources-%%i
)
call :create_language_resource eng resources
echo done.
goto :eof
:create_language_resource
echo creating %2\language.xml for language %1..
if exist %2\language.xml (
del %2\language.xml
)
if not exist %2 (
mkdir %2
)
if not exist %2\language.xml (
> %2\language.xml (
echo ^<resources^>
echo ^<strings^>
echo ^<string id="language"^>%1^</string^>
echo ^</strings^>
echo ^</resources^>
)
)
And then this code can be used to get the language as a string resource:
var lang = WatchUi.loadResource(Rez.Strings.language); System.println(lang);
All that said, there are just a handful of reasons I can think of that would require doing something like this. Are you sure that this is what you need to do?
for me, like Travis.ConnectIQ said, I can think of only one of my apps where I use this - requesting data from a website in a specific language.
Are you just looking to localize your app? If so, maybe look at the "Strings" sample in the SDK.
Thanks.