I want to get the language of the device (macOS). All I found is a bunch of examples for the app itself or the prefered user setting, not the device itself:
Locale.preferredLanguages => ["en", "de-DE"] (I'm using english XCode, non localized app and german macOS)
I want to set the labels of the Finder as extended attributes the same language as the OS itself. For me it is "de", regardless of the localization of the app.
I also found some old tips (5 - 10 years old) which needed a lot of changes in code, but still don't work.
What's the correct function call to get the language used by the OS to set color names like "Rot" or "Red" later on? (e.g. "de" for my setup)
I found an solution:
((Locale.current as NSLocale).object(forKey: NSLocale.Key.languageCode)! as! String)
Related
macOS 10.15+ provides NSScreen.localizedName, which provides a user-facing name for the screen, such as "Built-in Retina Display" or "Встроенный дисплей Retina" (if local language is Russian).
However, I need to support macOS older than 10.15, and it's not clear what the fallback should be.
I see this question, "How to Get the Display Name with the Display ID in Mac OS X?". However, all answers use CGDisplayIOServicePort, which is unavailable in macOS >10.9.
I also see this question, "CGDisplayIOServicePort is deprecated in OS X >= 10.9, how to replace?". However, all answers depend on GLFW, an enormous library that I clearly don't want to include just to get the display name.
(EDIT) I also found this shim, "get display name from NSScreen", but it doesn't work properly - for instance, my "Built-in Retina Display" gets the odd name "Color LCD", and it doesn't find a io_service_t for my Sidecar iPad screen.
The screen's actual name is "Color LCD", but the user-friendly localizedName (and the one System Prefs shows in older OS versions) has an extra check to detect that it's a laptop's internal display.
My iOS-App was first German and English. As it was just a fault, I removed the English localization. Somehow if I change the language in the iOS Simulator to english not it loads the old storyboard that doesn't even exist anymore. I cleaned the folder and there is now only a base storyboard. Although I cleaned the Project the App is still crashing after start (because it's loading an old storyboard of prior App version (I removed english localization in 1.1, and now in 1.2 it still loads the 1.0 storyboard).
This is really weird, how can I achieve that the App ALWAYS uses the same storyboard, no matter which language? I already removed the english localization!
Thanks very much!
From my understanding based on a previous experience, if you are localizing an application you need to keep the English one. Because it will default to English if the device is not set in the language that you are supporting.
(Have you notice in the setting app how english is always the second choice and that you can't change the order like on the desktop to default to something else before english)
So if you are planning on supporting only 1 language remove all localization into your application. Because other wise it would default to a non-existing asset and crash.
That would be my best guest for a try.
Have you delete the application on your device after all those change and a clean up may be necessary. I've notice that file, (especially not code file) that get deleted have a tendency to lay around the executable.
And if you get file (1) b.xml and (2) fr.lproj/b.xml even if the device if in french the french one (2) won't get used. The system will see (1) first and think there is no localization for that file.
As for "losing" your German Xib. If you take a copy out of your de.lproj (and put that copy up a directory in the file system it should work)
I wonder How to trigger the localization language portuguese-brazil in iphone? (or simulator is all right)?
that's, how can I test Portuguese-Brazil localization on iphone?
I found there's only Portuguese and Portuguese(Portugal) in the international setting but unfortunately neither could be the answer.
Thanks in advance
Well, I am Portuguese, to trigger those, you should put the language as Portuguese. If it's not working on your case, might be a problem related with the code. Try doing the following:
Keep only 1 version of the Localized.strings file as the Portuguese version, remove everything else (just for testing).
Ok, i had the same problem and i just solved it.
Use "Portuguese" instead "Portuguese-Brazil" in your project, and your Portuguese language of device should work fine.
Here is the problem:
I was trying to set the portuguese language with Portuguese-Brazil at the "+" when i selected the project file, and when i changed my device and my simulator (used both to test) language to portuguese (once there is no portuguese-brazil), the text was coming from the default language (english), what means it was not working.
I tried deleting "Portuguese-Brazil" and adding "Portuguese", and it worked when i changed my devices to portuguese language;
I think that is a bug in XCode, that language "Portuguese-Brazil", since the device has no language like that in Settings > General > International> Language of devices, only "Portuguese"
Maybe you're looking at the wrong setting. To change the language in iOS, go to Settings > General > International > Language. There is also Settings > General > International > Region Format but this setting controls things such as date, time and number formats (i.e. locale formats, not localization)
When you change the Language setting, even in the simulator, you will see that the iOS user interface will have changed to the new language. If you then launch your app and you don't see it localized as you expect (assuming that of course you added the localized resources in that language), then something is wrong!
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
iPhone App Localization - English problems?
Currently, I have a localization strings file for Mexican Spanish. I do not have a plain Spanish strings file. I would like to have my app be localizable for this particular dialect of Spanish, and so in Xcode 4, I added Spanish-Mexican. I have a Localizable.strings (Spanish-Mexico) file generated by Xcode 4, with Spanish strings added. But when I go into the simulator and change the International settings to Español for Language and Mexico for region, the strings are not displayed, but the default English ones appear instead.
However, in the Simulator when I set the language to Spanish, and the Region Format to Mexico, the strings do not appear, but the plain English is displayed instead. Is there any way to support dialects in iOS 4, not just the languages that appear under Languages? There is the extensive Region Formats preference, but I'm uncertain how it's actually used.
I understand that Locale and Dialects are two different things. But other for different formatting to represent their files (underscore vs. hyphen), how do we use them in iOS? And is Locale and Region Format the same thing?
Relevant threads with the same problem:
iOS localization with region (de_LU)
iPhone en_* sublanguage localization
Hack-y workaround:
http://hamishrickerby.com/2010/07/23/iphone-ipad-localizations-regions/
Looks like it's currently unsupported:
When searching for resources in Mac OS X, the bundle interfaces take into account the user’s preferred region settings in addition to the preferred language settings. For languages that have multiple dialects, an application can specify custom resource files for each region. For example, for the English language, an application might include different sets of resource files for users in the United States, Great Britain, Canada, and Australia. By using the user’s preferred region settings, the bundle interfaces are able to return even more precisely localized content to the user. This support is available in Mac OS X only, though; in iOS, only the preferred language is taken into consideration.
http://developer.apple.com/library/ios/#documentation/MacOSX/Conceptual/BPInternational/Articles/InternatSupport.html
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
iPhone App Localization - English problems?
I am working on an App for iOS devices. I made it available for English (en) and German (de). That works fine with localization. Now I want to create a specified localization for German with region Luxemburg: German (Luxemburg) or de_LU.
I added it into my Localizable.strings but nothing happened... I deleted the cache, I reinstall the app serval times: Nothing. He ignores that.
My iPhone is configured with the German language and Luxemburg as region.
Where is the problem? Or is it impossible to do that?
It is possible, to localize into that culture you should have a de-LU.lproj folder, is that the case?
A typical application has at least one strings file per localization, that is, one strings file in each of the bundle’s .lproj subdirectories. The name of the default strings file is Localizable.strings but you can create strings files with any file name you choose.
(Quoting Apple documentation)
If you're using Xcode 4, just go to project settings, Info tab, then add your localization from there, it will setup the project accordingly for you.
Also note that Apple recommends that you save strings files using the UTF-16 encoding
Check for region & language in code. If language German & region Luxemburg then keep new key for localization.And initialize that key in German language localized file. It is working for me.
Unfortunately, I believe that supporting dialects is currently impossible in iOS 4.