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
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.
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 ^^
little missunderstanding 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
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, 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 ( ) 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.
The problem is that your ampersands (“&”) are changed to “&” when they are sent from the game (the oak_log.json) to the GUI. Give me a second, I guess…
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.
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
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) + "\",";
}
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?