How do I read and write to the Language key in MyGameEngine.ini?

I can see it when I open the file with a text editor. How do I access it via UnrealScript while the game is running?

I was never able to update the “Language” param during gameplay. I ended up implementing my own localization system because of this.

I guess you could create a ddl bind to update the param in the .ini file, and then force a game restart, but I wanted to be able to switch quickly while in-game.

Pretty sure this was an oversight with UDK. If you figure out how to do, please do share with us.

Thanks @ I’m trying to figure out what would be easiest at this point. I’ve started on my own localization system. But now that I’m looking at how much work it’s going to be, I’m digging deeper into this approach.

Take a look in UnObj.cpp at UObject::GLanguage, UObject::GetLanguage, and UObject::SetLanguage. GetLanguage is exposed to UnrealScript. It looks like SetLanguage is not. Do you know how to change that? My UDN account expired a long time ago, and I didn’t keep local copies of the documentation.

Edit:

I don’t know anything about C++, but I think this is what has to happen in order to expose SetLanguage to UnrealScript.

Object.uc


native static final function SetLanguage(string LangExt, bool bReloadObjects);

UnObjBas.h


DECLARE_FUNCTION(execSetLanguage);

[Edit: Updating this with the function that works correctly.]
UnCorSc.cpp



void UObject::execSetLanguage(FFrame& Stack, RESULT_DECL)
{
    P_GET_STR_REF(A);
    P_GET_UBOOL(B);
    P_FINISH;
    SetLanguage(*A, B);
}

And like I said, I don’t know anything about C++. I am most uncertain about what needs to go inside execSetLanguage. I don’t know what else needs to be done, but I think I’m on the right track.

Edit 2:

Nope. It compiles, but SetLanguage crashes the game. I have no idea what’s supposed to be in there to make UnrealScript Object.SetLanguage call C++ UObject::SetLanguage.

Edit 3:

It works! When I run Object.SetLanguage, and then Object.GetLanguage, I can see that the Engine’s language has changed. Now I just need to figure out how to save it.

Maybe I just need to figure out how to expose GLanguage to UnrealScript. Then I should make a function that sets GLanguage and then calls SaveConfig.

Possibly making progress. New compile error. I wish I had studied C++ before now.



void UObject::execSetLanguage(FFrame& Stack, RESULT_DECL)
{
   P_GET_STR_REF(A);
    P_GET_UBOOL(B);
    P_FINISH;
    SetLanguage(*A, B);
}


What I think is happening is that execSetLanguage is the function that I’m supposed to use to connect UnrealScript SetLanguage to C++ SetLanguage. The problem is that UnrealScript sends a string (edit: which automatically gets parsed into an FString, I think) and C++ wants a tchar. There are a bunch of macros in UnScriptMacros.h for getting the necessary variables, but I don’t see anything that converts an FString to a tchar. I just Googled how to do that, and it looks like a straightforward conversion, but I would imagine that UE3 must already have a way of doing that already. [Edit: I was looking for how to convert strings. UE3 FStrings are something completely different.]

And I hope I’m OK with the NDA so far. I haven’t copied any existing UE3 code here. This is all just stuff I’ve added while trying to figure this out.

Edit: I just updated the code. It works. I can confirm that the language changed when I call GetLanguage. I still need to figure out how to save the setting though.

I was looking into this and found that the language in the engine config folder in file BaseEngine if changed to CHN it will read the CHN file but only if its in English fonts. I changed the file to Chinese fonts but it printed English. Is that because the fonts being used are English. What I’m wondering is if you change the fonts to chinese and the language to Chinese will it change to Chinese fonts?

In the engine file you can set which fonts are used in the config. So in short if we change the language and the fonts in the configs will it read the right ones and print the right ones?

Sorry, I’m not that far along yet. I would assume it would work that way though. You set the font, and assuming that the given string is in Chinese, I think it would show up in Chinese, in the font you set. I don’t think I’m going to rely on that though. 100% of my GUI is going to be Scaleform.

OK, it’s done. There are just a couple more things you have to add.

Engine.uc


var globalconfig string Language;

Then rebuild C++.

Then wherever you want to change the language…



    local Engine GEngine;
    SetLanguage(NewLanguage, true);
    GEngine = class'Engine'.static.GetEngine();
    GEngine.Language = NewLanguage;
    GEngine.SaveConfig();


Hey gamepainters, are you talking about the fonts in MyGameEngine.ini?



TinyFontName=EngineFonts.TinyFont
SmallFontName=EngineFonts.SmallFont
MediumFontName=EngineFonts.SmallFont
LargeFontName=EngineFonts.SmallFont
SubtitleFontName=EngineFonts.SmallFont


One of my Japanese players can’t type Japanese into the console. Also, messages like “paused” and “loading”–with defaults set in Engine.INT, and Japanese versions in Engine.JPN–show up as rectangles in Japanese–presumably because the font doesn’t support Japanese. (And as an aside, does anyone know how to disable those messages? I just set them to blank in my localization files so they don’t draw, but I’d like the game to not even look for them.) Have you tried copying the font settings into Engine.CHN, and then pointing them to your Chinese fonts?

Edit: I added a font, with all the Japanese characters, and I added an [Engine] section with the new font to Engine.JPN. It looks like the engine still doesn’t support Japanese after doing that. And I checked Engine.uc, and it’s not a localized variable. Anyone know what else needs to be done to change the font with the language?

Yeah, those are the ones I was talking about.

Also in binaries folder there is UnrealLoc.exe to make the rest of the languages INI files, but I think for them to be made right we must have the fonts added or they all come out in English, then you will need to translate each one to the font you installed. still haven’t got far enough yet to confirm that this will work. I do know if you set the language to what ever udk reads. If you use GetLanguage() it will return the one you have set in the language var.

What I have not did is install fonts yet to see if it reads them and uses them and if my ini files are in those fonts will it print them. I tried it without the right language fonts in and it printed in English. I took and edited one line in the CHN folders file to some thing different then the English one and it printed the line in the Chinese file as long as it was in English. When I put Chinese fonts into the ini file it read them from the int folders file and printed the English from the int folders file line. So what I was wondering is if I get the right fonts added into a package then set those fonts will it print them from the Chinese file in the Chinese folder. Enstead of using the English ones. I’m thinking that beings the English fonts are set to the English ones that is why it’s printing them in English.
Once I get 1 languages fonts in, I will try the rest and report back what I find.

Edit: Also when you look at the fonts used in the engines config file and find them in the package each font that being used has different setting on each letter in the file, so it can be read from the right spot in the file, all 256 of them. I’m pretty sure if we don’t do the same to place them in the right spots to be read from it wont pull the right characters for you from the file.

When you import a font, you can set which glyphs you need. Also, you can change the size of the page that the glyphs get saved to. For my Japanese font, I’m using 512x512. And I think you can change the default fonts in [YourGame]\Localization[3-letter language code]\GFxUI.[language code]. In that file, create a [Fonts] section and fill it in with the font you want to use:



[Fonts]
TinyFontName=RPGTacContent.Fonts.Japanese_16
SmallFontName=RPGTacContent.Fonts.Japanese_16
MediumFontName=RPGTacContent.Fonts.Japanese_16
LargeFontName=RPGTacContent.Fonts.Japanese_16
SubtitleFontName=RPGTacContent.Fonts.Japanese_16


If you do that, can you use Chinese characters in your game?

I have not made the font table yet. I found the fonts in the UDKGame\Config\DefaultEngineUDK.ini file.

[Engine.Engine]
TinyFontName=EngineFonts.TinyFont
MediumFontName=MultiFont’UI_Fonts_Final.HUD.MF_Medium’
LargeFontName=MultiFont’UI_Fonts_Final.HUD…MF_Large’
SubtitleFontName=MultiFont’UI_Fonts_Final.HUD.MF_Medium’

then below that it looks like you must add in your fonts package to be cooked.

[Engine.StartupPackages]
+Package=UI_Fonts
+Package=UI_Fonts_Final

EDIT: Found this https://docs.unrealengine.com/udk/Th…tingFonts.html
Be sure to set the bCreatePrintableOnly flag, along with the filepath & wildcard. You may experience problems where the characters will not import properly that checkbox is not set properly.

Nathaniel3W](FPS Animations help - Character & Animation - Epic Developer Community Forums) did you get the fonts to make a package for you? I can’t get the package to save. nothing shows up. I must be doing something wrong when trying to make the fonts package.

I saved my fonts in my own package. I didn’t have to do anything unusual; I just opened the content browser, selected the package I wanted the fonts in, right-clicked and selected New Font. After I set it up, I saved the package.

Hi @Nathaniel3W, did you make a deal with epic games and got C++ code?

I got the C++ code directly from Epic. If you want the UE3 source, you can ask on the custom license terms page. Other licensing options - Unreal Engine