Translation problem ( Chinese )

I am trying to put the game to translate into Chinese, but I had a problem.
When I translate Chinese in utf-8,

  • First convert Chinese to utf-8
  • Put utf-8 replace text in a file, such as “name”

This is I can translate the documents, and other text without translation, I encountered problems (see below)
here
Hope to be able to solve
@Tom @Ponder @SteveAdamo @tkh @voxel_pirate

Picture Description:
oak_log.json file:


Replace English utf-8:
in the game:

en.json file:
new game change oak_log

in the game:"

Now the picture is normal, no translation errors:

like i have mentioned in another topic it looks like it you turkish or baltic ISO ingame - so it doesnt us UTF-8 ingame

Ok, now I want to radiant energy to solve this problem,

Wrong, because what @law has discovered is actually pretty interesting, I’m not sure if this came up yet:

  • Encoding the characters as html entiites does work - so the characters can be rendered. CEF is merely not recognizing them for some reason. So as a work around, they could simply manually translate the UTF8 to its entity form and have compatibility. Of course, that would disallow using HTML in locales, but I think strictly separating view and data is a good idea.
  • For items, it doesn’t work because it is encoded, or at least it’s escaping the ampersand.

Paging @sdee - do you think that could be a possibility to simply display the characters as entities? I’m not sure where the names from the game itself are encoded, but I guess it either happens during the transfer from the client/server state or at the receiving end in JS.

I’m sure @tkh could implement this into his translation program (decoding the entities during loading and encoding them durinv save), so he could be already ahead of this.

1 Like

ok this post was only for him ^^ i have test it with the chinese symbol for tree 木 and everytime its change them to 木 ingame and thats the turkis/baltic iso ^^ in the mainmenu it works only ingame not ^^

It works everywhere where the locale.json is used.

It doesn’t work on stuff that’s queried from the server/client because of the aforementioned escaping.

little missunderstanding :wink: with ingame i mean entities etc. ^^

you have right it works with all infos in html - mostly the mainmenues or the esc menu ^^ just the json und luac (doesnt tried) files doesnt accept them

These are successful translation:

5 Likes

I checked the file “unit frame. HTML”. I think you can look at. I don’t understand programming. @RepeatPan @Wiese2007 @Tom

  </div>

  <div id="info">
     <div class="inner">
        {{#if stonehearth:job}}
           <div id="jobButton" title="Show character sheet">
              <img {{bind-attr src="stonehearth:job.class_icon"}} />
           </div>
        {{/if}}
        <div id="nameBlock">
           <div class="name" title="Focus camera on this unit">{{unit_info.name}}</div>
           <div class="description">{{unit_info.description}}</div>
        </div>
     </div>

     <div id="commandButtons">
        {{#each stonehearth:commands.commands itemView="stonehearthCommandButton"}}
           <a {{bind-attr id=this.name}} href="#" {{action "doCommand" this target="view"}} class='uisounds'>
              <div {{bind-attr class=":commandButton enabled:buttonEnabled:buttonDisabled" hotkey=view.hotkey title=tooltip description=description}}>
                 <img {{bind-attr src="icon"}}>
              </div>
           </a>
        {{/each}}
        <div id="backpack">
           {{#if backpackFull}}
              <div id="full">{{i18n stonehearth:backpack_full}}</div>
           {{else}}
              <div>{{stonehearth:backpack.num_items}} / {{stonehearth:backpack.capacity}}</div>
           {{/if}}
        </div>
     </div>

  </div>

ok now its again the problem with the understanding ^^ whats the issue? do you want to know where you must translate? or doesnt accept your translation?

I want to by changing the code, the “name” can be translated.But I don’t know how to code.By the way, you can also add a picture in front of the name, write the words in the picture. This is feasible?

so you will set a link so that you can enter the change in local/en.json … when you mean this you can use in html {{i18n stonehearth:description_XXX_XXX}} but its better if you dont touch this - the devs will change this when needed^^

Ok, let me study. It use utf-8 translation, succeed?

"木头"    =     "&#x6728;&#x5934;"

You try, whether it is feasible?

Ok, I don’t know if I fully understood the method to make things work in Chinese, but it’s a good lead for Team Radiant!

Since @RepeatPan challenged me ( :wink: ) I gave the HTML thing a shot. But with Swedish locales I can’t see any difference from before.

Very temporary release for my program, test this:
edit: was something wrong with the link…

  • link removed -

In this version, there is a checkbox next to the save button. This means that it will recode the tags to HTML on export. Only the strings with data (json value and string) will be recoded, not the “” : things.

IMPORTANT: It does not work on import files, so make sure to use double files!!!

Also use the settings page, because the file will be exported in an encoding format still, so use default/utf8/utf8-noBOM and try with the HTML function and see how it looks for the main file.

Come on! I believe you can do it! After the success will become everyone’s hero.!!!

The problem is that your ampersands (“&”) are changed to “&amp;” when they are sent from the game (the oak_log.json) to the GUI. Give me a second, I guess…

Basics: I’m sure you’ve heard about the ASCII table; each character has a value attached to it (a byte). In unicode, instead of a byte, it’s several bytes (i.e. a bigger number). HTML supports this as entities, whereas the character with the number “169” (©) would be © (&#0169;).

Your program would now need to find characters whose value is >255 (unsigned; 127 signed) (or who are unicode) and replace them with &#value;. Most likely, normal .NET encodings will only replace the HTML tags (<, >, &, ", ') with entities. We need to replace

I’ve found, but haven’t tested, this snippet here that might work. Can you show me the code you’re using to encode it/the output of your program?

Edit: Yepp, that function works. If you use it to encode your values, it should work.

Input: (╯°□°)╯︵ ┻━┻
Output: (&#9583;&#0176;&#9633;&#0176;&#65289;&#9583;&#65077; &#9531;&#9473;&#9531;
Output in HTML: (╯°□°)╯︵ ┻━┻

This sentence mean I output is to use what way?

This symbol can be displayed on the web (web=html???)

I was talking to @tkh. :wink:

Yes, but not in Stonehearth.

"settings_title" : "(╯°□°)╯︵ ┻━┻", "settings_graphics" : "(&#9583;&#0176;&#9633;&#0176;&#65289;&#9583;&#65077; &#9531;&#9473;&#9531;",

Again, I have a link to my latest test version in my previous post, you can try it if you want to @law

Sure, here it goes :blush:

Added checkbox next to “save as”-button.

private void chkbx_html_CheckedChanged(object sender, EventArgs e)
{
    if (chkbx_html.Checked)
    {
        isHtml = true;
        writeLog("Will use HTML in export.");
    }
    else
    {
        isHtml = false;
        writeLog("Will not use HTML in export.");
    }
} 

Added a reference to system.web dll… so:

using System.Web;

Added a new function in my class. When thinking about it, should not need to encode the tag name… only the translation… hehe. Anyway, the normal one first:

//Returns a JSON formatted row with both tag name and translated value ready for export
public string PrintJsonRowTrans()
{
    return "\"" + tagName + "\"" + " : " + "\"" + tagTrans + "\",";
}
        
//Returns a JSON formatted row with both tag name and translated value ready for export but in HTML. 
public string PrintJsonRowTransHTML()
{
    return "\"" + HttpUtility.HtmlEncode(tagName) + "\"" + " : " + "\"" + HttpUtility.HtmlEncode(tagTrans) + "\",";
}

Last thing is when I export the data to a file:

if (isHtml)
    wr.WriteLine("    " + allData[i].PrintJsonRowTransHTML());
else
    wr.WriteLine("    " + allData[i].PrintJsonRowTrans());     

And again, I still have to use an encoding to export the text… so we still have default/utf8/etc to pick from.

Original file:

    "decline" : "Avböj",
    "back" : "Tillbaka",
    "next" : "Nästa",

And the new output:

    "decline" : "Avb&#246;j",
    "back" : "Tillbaka",
    "next" : "N&#228;sta",

By using html entities, you can encode everything as normal windows codepage (1281?). Don’t use UTF8 for that - I don’t think that either # or & will be translated, but plain latin1 should be enough now.

Also, the new output file seems to work fine for me (works at least). I can see Nästa fine in the game… Can’t you?