Get current locale

Hi!

I’m with a problem using translation.

on a label.opening() i have this:
Me.Text = kAbout

and kAbout is this:

i’m testing on a windows machine in portuguese (pt-br) and it’s not showing the text!

How do I get the computer’s locale to check what’s going on on my code?

Alex

Docs are your friend :wink:

1 Like

yes, sure. thank you Jason!

Sometimes i think I’m stupid and even give a mischievous little laugh…

on my mac:

on windows (remote debugger):

Could it be that when the xojo command returns much more than just “pt-BR” it doesn’t work correctly?

before enter the me.text = kAbout:

after:

You don’t need to do this. You can simply place the constant in the IDE. Precede it with a #.

If the constant is defined in a module or elsewhere then you can use:

In code you don’t need the #, in IDE inspector you do.

In terms of why it doesn’t show it could be a mismatch in locale. Xojo uses names, rather than codes it could be your Interface it pt-br but Xojo is expecting something else by Portuguese Brazil.

2 Likes

indeed very much easier!! thank you. so obvious!

but… the problem persists.

on my mac (us-EN):

on remote debugger on windows (pt-BR):

Is Localized turned on on the Constant? It needs to be.

yes!

i guess…

on this windows machine, the return (on xojo) is this:
image

All I can think of is that there could be a problem with the remote debugger choosing the right language. You could try building the app and transferring it manually, see if that solves the problem.

iI had already done this test. It doesn’t translate!

Could you add this as a bug?

Odd that the identifier on Windows comes out as ‘pt_BR@calendar=gregorian;currency=brl;fw=…’ and on Mac just ‘en_BR’. I don’t have a windows machine to try it on.

What does currentLocale report?

on mac:

on windows:

Windows 11 Home Single Language
Version: 24H2
Compilation: 26100.4351

Ah, I didn’t realise that was what it was showing. All that stuff seems wrong, as I said. If Xojo doesn’t match the language then it uses the Default language. Which is defined on the Shared Build settings. as a work around you could change that to do testing.

yes. this work around worked.

Could you add this as a bug? Or i need to open a case?

You are best adding a but report. I don’t work for Xojo. You are best to create a small working example project. Just create a new project and copy your constant and label into it. Check it still fails, if so attach it to your report. Attach your screen shots showing the locale output.

If it works then you need to figure out what’s different with your app.

You could try adding a new user to the windows machine, set the setting correctly and see if the problem persists.

According to Xojo docs Identifier is supposed to just be the “pt_BR” part. Which either means that there is a bug is Xojo that isn’t reading it correctly. Or Windows is, for some reason, returning the wrong thing.

1 Like

Keep in mind that the info you get from Locale is probably not the same as what’s used for Constants. I would create a constant that includes all of the languages that you support as well as the once’s that are close whose text value is also the name of the language and put it in a simple little project and run that. You may find that xojos language constant is revealing something else on windows.

i’ve created a bug report. thank you all for your help.

alex

Here the bug report:
#79660 - locale not working on windows?

maybe someone that can test Windows can review.

If you change to only Portuguese, it behaves the same?
If you change the Build settings Language from ‘Default’ to ‘English’ does your app behave the same?

Just testet on Windows 11: Xojo is using “Portugese” instead of “Portugese Brazil” for the language constant, if the Windows language is on “Portugese Brazil”. If this is a bug, it may be easily fixed.