Hi, I’m trying to get the language used by the Operating System (e.g what language Windows is in) for my game, so it can detect it and automatically change to the appropriate language. I can’t figure out how to do C++ programming for the life of me - and I cannot find anything even slightly related to what I’m trying to do. At the moment I have:
.h file
UFUNCTION(BlueprintPure, meta = (DisplayName = "Get Current Language"), Category = "Locale")
static FCultureRef getLocalisation();
I’m really not sure what I’m doing wrong - or what I’m really doing at all to be honest - I tried using FText but it kicked out tonnes of errors and this code only brings up one error complaining about how I’m using FCultureRef.
4.17 (maybe 4.16) adds BP support for managing the language and locale of your game, so take a look at UKismetInternationalizationLibraryif you want an example of how your 4.15 version could work.
I’m trying to get the language used by the Operating System (e.g what language Windows is in) for my game, so it can detect it and automatically change to the appropriate language
Im currently testing with French set as my language and it didn’t automatically change - and the new internationalisation options seem to have completely broken my localisation - as I can’t even use my old code to change to french anymore.
I updated to 4.17, Im going to try adding said code into 4.15 and see if that works.
Im currently testing with French set as my language
How did you change your language, and which Windows version are you on?
You can always test French by passing -culture=fr on the command line when starting your application.
Actually just found out that the translations have now completely broke across the board on both 4.15 and 4.17
Assuming you’ve edited your translations via a PO file, you may find you need to re-gather, re-import, and re-compile after upgrading to 4.17 (some of the internal keying has changed, but the external PO keying hasn’t so can preserve the data for you).
The same would be true of trying to take localisation data gathered in 4.17 and using it in 4.15, and is why you should always translate via the PO files rather than hand edit our archives.
Ah, that. There was a change to the way that empty arrays were imported in properties that
inadvertently affected localisation targets in the dashboard.
You’ll want to double check any array properties in the Localisation Dashboard as you’ll find they have extra empty entries at the end, and you should delete those entries. In particular there will be an array of extra modules to import, and it’s the empty entry in that one that is causing the import error.
I chose to go for long winded copy and pasting translations in to make sure I did it just how I put it into UE 4.15 originally, as I couldn’t find any empty arrays, entries or anything of the sort.
Still though - the game doesn’t change language. I binded a key set to “G” to swap between French and English, and whilst the game does lag and appear to change, nothing changes at all.
They don’t update when changing the culture, even destroying them and then re spawning them does nothing - it just stays in the Native Language. I know it’s been localised in the dashboard as when changing the “Is localizable” from yes to no, and back again - it re appears in the localisation dashboard as if it was never in their to start with.
Nevermind, I figured out the problem about the TextRenders not changing language, it was a stupid error where I forgot that ‘append’ can’t be localised, whereas format text can be so I have moved to them.
On a serious problem for me though - when localising you can using ‘TAB’ spacing or new lines in the localisation - this is a huge problem for me as a use ‘TAB’ spacing in my controls menu, and I need new lines for my key prompts.
They should be updated by FTextRenderComponentCultureChangedFixUp which binds onto the OnTextRevisionChangedEvent event to dirty their render state so they refresh to show the new text.
Can you confirm that FTextRenderComponentCultureChangedFixUp::FImpl::HandleLocalizedTextChanged code is being run when the culture is changed? It’s in TextRenderComponent.cpp in Engine\Source\Runtime\Engine\Private\Components.
Although the fact that re-spawning them doesn’t update the text would suggest another issue. How is the text set on these components?
The translation editor (which is separate to the localisation dashboard, but linked from it) is quite an old tool. It was written before multi-line editable text was a thing, and hasn’t been touched in some time.
It would be better to edit your translations via PO files, and you can always use something like PO edit if you want a tool to help with that. There aren’t restrictions on whitespace or new-lines in localised text, it’s just that our translation editor is too old to handle such things.
When in English translation, the TextRender I’m using shows both the lines - however upon changing to any other language, the second line of the TextRender doesn’t appear.