Skip to content

Conversation

rogerfachini
Copy link
Collaborator

This should translate the colorsets successfully. Currently only the generic-standard colorset has translation files, though.

This is a proof of concept for #167 and #169, adds basic functionality
for translation the names of colors in colorsets while still keeping
them modular.  @techninja and I talked about the main issues with this
still, mainly including the namespaces in the colorset JSON file, and
the general functionality (or lack thereof) of translations in modes.
New translation file from @RI0
@techninja
Copy link
Contributor

Awesome, thank you guys for your work so far. This is complicated and hasn't been done anywhere in the system yet, there's likely to be some confusion in how to make it all work, or the best path, so there's likely to be a bit of discussion here.

Colors as numbers in translation key:

I mentioned in some late night video call that I was on the fence about non-specific color names. One of the whole points of translation string keys is that they are a source language reference, like generic.colors.blue, not generic.colors.color0. Of course in that same light, you wouldn't have generic.info.type, you'd have generic.info.generic... not very nice or obvious.

In a way, the translation files themselves define the content, why have a definition file filled with known expected strings that will be mostly the same? It's silly. Perhaps what might be better: Have the translation strings in the files as expected, in their current format of color0-7, type, manufacturer, etc... But remove any reference from the colorset definition file. IN that way, all the translatable strings stay in their translation files, and non-translatable stuff like what media it's for and the color values (as an non-keyed array).

Then when you want to output the translations, you simply know what key to use as it's standardized. Simplifies the format, and clarifies the use.

If you want I can submit a PR to your branch here so you can get an idea of what I'm talking about.

@rogerfachini
Copy link
Collaborator Author

I think I get the idea enough to not require you to make a PR to the branch. I think removing the i18n strings from the definition file will make a lot more sense than the system I had implemented. These are the things that I plan to change in colorset translation (serves as a list for me to follow and let me know if there's anything I should change further) :
- Name, type, description defined in i18n file rather than the definition file.
- color0-colorN will reference the non-keyed array of color values (color0 -> 0th position in the array).
- Refactor key names for colorsets (generic.colors.color0 will be colorsets.generic.color0) to make it more readable. (generic.info.generic could become colorsets.info.generic to consolidate it as well.

@techninja
Copy link
Contributor

Sounds good except: info.generic: "Generic" vs info.type: "Generic". That is to say this is about having the key be a version of the translated content vs a locked-in identifier. If we don't have anything referencing the translation key in "content" (the definition file), then we need to lock down the key so we can hard code the key, or at least most of it (less the prefix/context/namespace) :)

@RI0
Copy link
Contributor

RI0 commented Nov 23, 2014

Would it make sense to use the hex code as a key and then have
some sort of list that could be used in the colour sets?
000000, en-US, Black
000000, fr, Noir
000000, es, Negro

We should have all the English versions so any colour that does
not have a translation will be shown in English.

@rogerfachini
Copy link
Collaborator Author

We are planning on splitting up the data into two separate places: all the translation data will stay in the i18n files and the remaining data will be in the definiton file. The colors will be stored in a non-keyed array, like this:
"colors": [
"#000000",
"#FF0000",
"#FFA500",
"#FFFF00",
"#008000",
"#0000FF",
"#800080",
"#8B4513"
]

and the color definitions will look like this:

"color0": "Black",
"color1": "Red",
"color2": "Orange",
"color3": "Yellow",
"color4": "Green",
"color5": "Blue",
"color6": "Purple",
"color7": "Brown"

We plan on putting it so that color0 will be the name for the color in the 0th position of the non-keyed array.

Just committing the data files so @RI0 can see the format.
@rogerfachini
Copy link
Collaborator Author

@RI0 you may want to have a look at these files in my branch:
https://github.com/rogerfachini/robopaint/blob/Colorsets-i18n/resources/colorsets/generic/generic.json
https://github.com/rogerfachini/robopaint/blob/Colorsets-i18n/resources/colorsets/generic/i18n/en-US.json
We changed the format up a bit, so if you want to translate into this format feel free, I only had time to do the generic set as a test.
The hex code as a key idea works in theory, but not so well in practice. The key is supposed to represent the data in as verbose a way as possible, so while the hex code does a good job at keeping things compact, "colorsets.generic.#8B4513" does not do as good of a job at describing the content it contains. Making translations default to a certain language if missing is a good idea, and is certainly possible, though makes it less obvious if the translation is missing or if the word just wasn't translated from English. Any thoughts @techninja ?

@techninja techninja added this to the 0.9.5 milestone Nov 24, 2014
techninja and others added 2 commits November 26, 2014 14:53
Adjust globe icon location for language select menu
After a VERY busy week of me not having time to work on robopaint, I
finally got colorset translations DONE and WORKING (for the most part)!
I was only able to port the colorsets over to English, but this gives
our translation gurus a template to work off of. Anyways, here's a
feature list:
- Added i18n folders and en-US translation files for respective
colorsets
- Modified colorset definition files to move all text elements to i18n
files.
- Modified colorset parser to get text from i18n file and reference a
non-keyed color array.
@rogerfachini
Copy link
Collaborator Author

Just got colorset translations to work! Before this is ready to be pulled, we need translations for colorsets for Spanish and French. If you switch languages in a colorset other than generic you get a FOVBBUC (Flash of Very Big Butt Ugly Content) due to a lack of translation file for that colorset!

@techninja
Copy link
Contributor

Roger and I have discussed this in great detail over an hour or so and we should be in good shape to make this real very soon. Translations of color names will be easier, the format is simpler (mostly), and the general readability and output will be cleaned up.

@rogerfachini make sure to post screenshots in two languages when complete :)

After some very through discussion with @techninja, we decided on this
new format for colorsets that is more translation friendly.
- Global colorsets i18n file for color and media names
- definition files give the media, a machine name for referencing
translatable text, and colors in a non-keyed array but with keyed colors
for translation.
- individual colorset i18n files give name, description, etc.
@techninja
Copy link
Contributor

Great work so far, though I think you'll need to re-merge current master before I can get this in. Also you've got a bit more work to finish up the format of non-crayola files. Seems right on track for 0.9.5, but not for 0.9.2.

@rogerfachini
Copy link
Collaborator Author

Not quite sure I can find what I missed in the non-crayola files. Been looking through them and they seem to match. Working on the parsing code now, should be done fairly soon.

"basetype": "colorset"
},
"info0": {
"media": "watercolor",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be no "media" here. Also the file name is wrong. Actually this whole file is wrong!

@techninja
Copy link
Contributor

The size of the drop-down seems to have.. gone full width :P And it seems you've forgotten to remove the bold titles & media type output. Remember, no titles, just a bold manufacturer, a dash, the name (same line), then a newline space, and the description. That, or leave it and make sure the translation of the media type gets in there and we deal with the re-layout of this for the Eggbot stuff that will be completely redoing it...

@@ -550,40 +552,48 @@ function getColorsets() {
continue;
}

// Move through all colorsets in file
// Move through all colorsets in file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't have to fix this, but look hard at every line in your commit diffs, it's easy to see little changes where you didn't intend that way.

Thanks to @docprofsky 's translator (with a hotfix by me to get it to
work), we now have preliminary translations for the other languages!
// Report language switch to the console
console.info("Language Switched to: " + robopaint.settings.lang);
// Reload and reparse colorsets
getColorsets();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is likely an unfortunate requirement. You either have to pull out string output from initial load, or you can reload the data over again. I suspect there's some efficiencies to be had in refactoring some of getColorSets(), but it's a very low volume function and as long as you've got it working, we're probably just fine :)

@rogerfachini
Copy link
Collaborator Author

Ok got the VERY fast translations in, there are some mistakes that we may have to catch later, but for now it works. Thank you for the present by the way. And just to clarify, the 🍰 is not a lie!

@docprofsky
Copy link
Collaborator

@rogerfachini Can you submit a PR with the fix? I tested it and it seemed to work fine (other than it changing the order of the JSON).

"creator": "rogerfachini"
},
"metallic": {
"description": "Prang m\u00e9talliques Aquarelles 8 semi-humides, set 8 couleurs",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason, by default Python JSON output is ASCII safe, and therefore doesn't store the actual non-ascii unicode chars as the actual chars. Every part of our workflow should be Unicode safe, so I'd suggest seeing if you can't tweak the output as explained here.

@rogerfachini
Copy link
Collaborator Author

@docprofsky its not worth PR-ing: I just removed the command-line arguments (I wanted to run the script from my editor to make it easier) and made it easier to translate 10 or so different files in a row and get them into my repo.

@rogerfachini
Copy link
Collaborator Author

Oh and for comparison: here it is with the fixed files:
translation-fr-good

@techninja
Copy link
Contributor

@rogerfachini Make sure the colorset dropdown doesn't randomly change width, that the JSON problems noted above are fixed, that the media type translates, and I'll merge it.

@rogerfachini
Copy link
Collaborator Author

The colorset dropdown is due to the largest item in it (In the broken translation picture this was due to the raw translation string being outputted, in the last picture the largest item was the french translation for 'add custom colorset', so that shouldn't be a problem). @docprofsky can fix the python side of the translation file issues but for now I will fix them manually. Should I just remove the media type from the list completely as it is unnecessary at this point (but can be re-added later)?

@techninja
Copy link
Contributor

Translate it. Better to correct what's there than pull out too much before a big refactor.

@techninja
Copy link
Contributor

And yea, make the JSON changes by hand, should be happy :)

Translate the media, too.
Fixed all the glitches caused by @docprofsky 's very-much-in-beta
translator!
@rogerfachini
Copy link
Collaborator Author

That should fix all the annoying glitches in the translate files.

"yellow": "Amarillo",
"yellowgreen": "Verde Amarillo",
"redviolet": "Rojo Violeta",
"orangered": "Orangered",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😢 It appears "orangered" is not a translatable color. See if you can't cherry pick that to just be "orange red" before translation :P

@techninja
Copy link
Contributor

REALLY close now! I can feel it. Fix the two little issues I've got there, upload a new screenshot and I'll merge this thing in!

@rogerfachini
Copy link
Collaborator Author

We shall miss you, Estrellarse (which apparently when translated back into English means 'crash'):
note the lack of star-butt

@techninja
Copy link
Contributor

Ok, ok. No need to hold this thing back for anymore petty crap. It is good (enough)!

techninja added a commit that referenced this pull request Dec 2, 2014
@techninja techninja merged commit 2733c69 into evil-mad:master Dec 2, 2014
@techninja
Copy link
Contributor

Let the race to get in the Chinese translations, begin! ;)

@rogerfachini
Copy link
Collaborator Author

And let the headaches ensue!

@rogerfachini rogerfachini deleted the Colorsets-i18n branch December 2, 2014 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants