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?
Announcement
Collapse
No announcement yet.
How do I read and write to the Language key in MyGameEngine.ini?
Collapse
X
-
How do I read and write to the Language key in MyGameEngine.ini?
Check out Himeko Sutori, the upcoming tactical RPG where you control armies of over 100 unique characters.Tags: None
-
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.
- 1 like
-
Thanks Coldscooter 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
Code:native static final function SetLanguage(string LangExt, bool bReloadObjects);
Code:DECLARE_FUNCTION(execSetLanguage);
[Edit: Updating this with the function that works correctly.]
UnCorSc.cpp
Code:void UObject::execSetLanguage(FFrame& Stack, RESULT_DECL) { P_GET_STR_REF(A); P_GET_UBOOL(B); P_FINISH; SetLanguage(*A, B); }
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.Last edited by Nathaniel3W; 11-12-2019, 04:52 PM.Check out Himeko Sutori, the upcoming tactical RPG where you control armies of over 100 unique characters.
Comment
-
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.Check out Himeko Sutori, the upcoming tactical RPG where you control armies of over 100 unique characters.
Comment
-
Possibly making progress. New compile error. I wish I had studied C++ before now.
Code:void UObject::execSetLanguage(FFrame& Stack, RESULT_DECL) { P_GET_STR_REF(A); P_GET_UBOOL(B); P_FINISH; SetLanguage(*A, B); }
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.Last edited by Nathaniel3W; 11-12-2019, 04:53 PM.Check out Himeko Sutori, the upcoming tactical RPG where you control armies of over 100 unique characters.
Comment
-
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?Last edited by gamepainters; 11-12-2019, 02:43 PM.
Comment
-
Originally posted by gamepainters View Post... 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?
Check out Himeko Sutori, the upcoming tactical RPG where you control armies of over 100 unique characters.
Comment
-
OK, it's done. There are just a couple more things you have to add.
Engine.uc
Code:var globalconfig string Language;
Then wherever you want to change the language...
Code:local Engine GEngine; SetLanguage(NewLanguage, true); GEngine = class'Engine'.static.GetEngine(); GEngine.Language = NewLanguage; GEngine.SaveConfig();
Check out Himeko Sutori, the upcoming tactical RPG where you control armies of over 100 unique characters.
Comment
-
Originally posted by gamepainters View PostI 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?
Code:TinyFontName=EngineFonts.TinyFont SmallFontName=EngineFonts.SmallFont MediumFontName=EngineFonts.SmallFont LargeFontName=EngineFonts.SmallFont SubtitleFontName=EngineFonts.SmallFont
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?Last edited by Nathaniel3W; 11-17-2019, 05:20 AM.Check out Himeko Sutori, the upcoming tactical RPG where you control armies of over 100 unique characters.
Comment
-
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.Last edited by gamepainters; 11-17-2019, 06:22 PM.
Comment
-
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:
Code:[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
Check out Himeko Sutori, the upcoming tactical RPG where you control armies of over 100 unique characters.
Comment
-
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.Last edited by gamepainters; 11-25-2019, 05:26 PM.
Comment
-
Nathaniel3W 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.
Comment
-
Originally posted by gamepainters View PostNathaniel3W 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.Check out Himeko Sutori, the upcoming tactical RPG where you control armies of over 100 unique characters.
Comment
Comment