Language determination no longer works on macOS Sierra

I recently updated my Mac to macOS Sierra. Now I face a strange and quite dramatic issue with my software projects. Hope you can help:

In the past I set up multi-lingual projects by using dynamic constants like this:

Platform: Any, Language: Default, Value: “Default text shown if nothing else matches”
Platform: Any, Language: English, Value: “English version”
Platform: Any, Language: German, Value: “Deutsche Version”

This worked well. A French user would see the “default” value, a German user the German one and so on.

In macOS I have specified multiple languages, German and English. It always used the primary language. Anything is correct.

Now after updating macOS Sierra, this runs strange. With above example and my language set to German, I see the text output used as default value instead of. It seems that macOS breaks the language determination using dynamic constants.

I could fix this only when building a separate version and adjust the build language each time.

It will also work when removing the “default” entry of the constant. But doing so leads to not showing any text to a user having set up French (anything except German and English in my example).

I’m using Xojo 2015 release 4.1 - is this fixed a newer release ?

Anything else I can do ? Unfortunately, I don’t have a second Mac for building software. But updating my apps would lead into losing the multi-language feature.

Playing a bit with the build settings comes up a strange - but hopefully working - method of solving this issue:

Same example as above. I have a dynamic constant configured like this:

Platform: Any, Language: Default, Value: “Default text shown if nothing else matches”
Platform: Any, Language: English, Value: “English version”
Platform: Any, Language: German, Value: “Deutsche Version”

If I now set a language NOT in my operating system preferences list like Albanian, I see the German version (since German is my default language).

If I remove the German entry from the constant, I get the default version.

Does this mean that I just have to set a build language that does not exist to keep the dynamic constants working? Is this a safe method?

Is there a logic reason behind why this behavior changed from OS X to macOS?

The behaviour hasn’t changed in years
http://blog.xojo.com/2013/12/17/how-os-x-chooses-a-language/
http://blog.xojo.com/2014/03/05/picking-a-language-at-runtime/

@Norman Palardy : Thank you, this answered my question. :slight_smile:

I also made some tests and found that the solution described in my second post (let build the app for a language that is not used by the dynamic constants) works. I gave it a try on macOS and Win 8.

Users can rearrange their language lists and OS X selects the language that is one of the ones you localize for that is closest to the top of the users list.
If there isn’t one then they get whatever “default” is - and in your case if you’re compiling on a German version of OS X that is likely German. If I were to compile your app then “default” would be English.

The reason they see German instead of “default” is that in your case German IS default and the more specific entries in the list are used instead of the one that says “default” - thats normal.

If you mean Default to be the “nothing else matched” then selecting some other language (not german or english) should work

I have set three languages for dynamic constants: Default, English, German. The build language is now set to “Latin”. Only with these settings, I get the expected behavior (German got German, English got English, French got English). Guess you meant that?

I find it interesting to discover that the operating system used to compile an app takes so much influence:

One week ago I compiled two apps under OS X Yosemite with the same Xojo release with “default” as build language. The behavior was as expected (German got German, English got English, French got English).

One app did not work under macOS Sierra for unknown reason, so I was “forced” to upgrade my OS to see where the problem is.

After upgrading to macOS Sierra, I compiled both apps. Both showed the “strange” (but now more logic) language behavior. And the app that refused to start under macOS Sierra starts smoothly - without changing a single line of code just by compiling it under macOS Sierra.

I thought that it does not play a role what kind of OS is used to compile. How does the OS used influence the build process?

You really have 2 IF your system is being compiled on a German OS

DEFAULT is NOT a language - it means that the values in “Default” are to be treated as being the strings for the language that the OS is running in WHEN THE APP IS COMPILED (not when its run)

Suppose a french user has their language list settings as

French
Italian
German
English

This user SHOULD see your app in German because their preference for seeing German comes BEFORE English

If you have a user that has the list set like

French
Italian
English
German

This user SHOULD see your app in English because their preference for seeing English comes BEFORE German

If you have a user that has the list set like AND you have not changed the build language and leave it set to Default

French
Italian

This user SHOULD see your app in German because there is NO match and YOU compiled the application on a German OS. So OS X language matching rules fall all the way back to the language in use when the application was compiled. And that was German as defined by the OS.

If you select the Build Language as Latin then this user would see the strings from the Default because there is NO match in the language list and so the OS uses the default strings.

@Norman Palardy , thank you for your very detailed reply and time you take to explain that thing to me. It may appear a very stupid beginner’s problem, but I think that I got it now (hope so).

The strange thing was just, that after upgrading to macOS Sierra, my apps built under macOS Sierra changed behavior, although I had the same language preferences set on my Mac: German, English

Building an app on mac OS Sierra with “Build settings”: “shared”/“build”/“language” set “default”, I see the English version. Although I have German set before English on my Mac and have a German dynamic constant in my app.

Building an app on OS X Yosemite I always got the German version (again, my language preferences never changed).

Changing the build settings (“shared”/“build”/“language”) to “Latin” (or any other unused language), the correct behavior returns on macOS Sierra.

According to your previous post, this is correct. So I’ll continue doing so choosing “Latin”. :slight_smile:

Just asked for curiosity: I had built an app on Yosemite that refused to run on Sierra. After compiling the same app on Sierra, it runs well on Sierra. The app is about 3 to 4 MB bigger now. Was there a problem with my last build on Yosemite?

[quote=322817:@Carsten Spengler]@Norman Palardy , thank you for your very detailed reply and time you take to explain that thing to me. It may appear a very stupid beginner’s problem, but I think that I got it now (hope so).

The strange thing was just, that after upgrading to macOS Sierra, my apps built under macOS Sierra changed behavior, although I had the same language preferences set on my Mac: German, English

Building an app on mac OS Sierra with “Build settings”: “shared”/“build”/“language” set “default”, I see the English version. Although I have German set before English on my Mac and have a German dynamic constant in my app.
[/quote]
That seems wrong
But you can see what is set for the default language in a BUILT application
In the Finder you can right click on the built application and select “Show Package Contents”
This will open a Finder window
Navigate INTO the Contents directory & in there you will see “info.plist”
Double click that (it may open in Xcode or Text Edit depending on what software you have installed)
Then look for a key in the XML named “CFBundleDevelopmentRegion”
The following line is the language that was in use when the application was compiled
This is “default” - the last fallback that OS X will use if there are no matches

No idea - there’s lots of reasons that apps might work on Yosemite but not Sierra

No. The same app works on Yosemite and Sierra when compiled on Sierra, but does not work on Sierra when compiled on Yosemite.

[quote]Then look for a key in the XML named “CFBundleDevelopmentRegion”
The following line is the language that was in use when the application was compiled
This is “default” - the last fallback that OS X will use if there are no matches[/quote]

The one that showed up in English language although I have set German as first language on my Mac contains “de”. But this showed up also in English as I removed English from my Mac’s preferences list.

The one compiled in Sierra now working as intended contains “la” as “Localization native development region”.

Am I correct when I assume the following:

I have localized constants for “Default”, “German”, “English”:

If user’s preference is set to German (considering that it’s just one language selected), the software shows up in German. If user set English on his Mac, it shows in English and if he sets up French as preferred language, it shows the one in default?

Yes - if french is the ONLY language in his preferred language list
Otherwise it will match whichever is nearer the top (as I’ve written before)

Not having followed the entire discussion I like to add something I learned many years ago and also documented in my article on localization for RB / Xojo (see chapter 4.4 of http://www.tempel.org/RB/Localization#toc16 ):

NEVER set your project-wide language settings to “Default”. Instead, set it to the language that your dynamic strings use as default.

I face the same issue with High Sierra :
A french OS switched to spanish —> french and spanish languages live together !
The date in the menubar is displayed in spanish (Lunes, 3 de septiembre)
but the date in Xojo is still in french (Lundi 3 septembre) !
In my applications the Services/Hide/Quit menu items are in french

I have the same behavior for computers that are only in spanish.