Announcement

Collapse
No announcement yet.

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

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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?
    Check out Himeko Sutori, the upcoming tactical RPG where you control armies of over 100 unique characters.

    #2
    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.

    Comment


      #3
      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);
      UnObjBas.h
      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);
      }
      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.
      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


        #4
        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


          #5
          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);
          }
          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.
          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


            #6
            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


              #7
              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?
              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.

              Check out Himeko Sutori, the upcoming tactical RPG where you control armies of over 100 unique characters.

              Comment


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

                Engine.uc
                Code:
                var globalconfig string Language;
                Then rebuild C++.

                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


                  #9
                  Originally posted by gamepainters View Post
                  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?
                  Hey gamepainters, are you talking about the fonts in MyGameEngine.ini?

                  Code:
                  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?
                  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


                    #10
                    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

                    Working...
                    X