Rearrangement of interpolations is generally necessary when there are two or more in the same string. Otherwise, an interpolation can occur in only three places: at the beginning before a fixed string, at the end after a fixed string, and between two fixed strings. These are relatively easy for the translator to deal with. We can similarly classify two interpolations as having at most three fixed strings separated by interpolations.
IMO dealing with this is not the highest priority problem that faces internationalization. The biggest problem is its cost to the programmer. Most internationalization makes your code ugly and takes energy and time to code. So, I wanted to handle the most general situation in the easiest way possible for the programmer, which is that you put t
, one letter and a space, before each string, even interpreted strings.
Paul Smith (of Lucky fame) pointed out that it isn’t sufficient to simply send interpolated strings to the translator, you should have some sort of comment system so that you can tell the translator what the things in the interpolations are. You see, in many languages those things have different genders, even though they are inanimate, and the translator can’t produce a good translation without determining the gender of your model field. Did you know that Switzerland is a female country and Germany is a male country, in the German language? Seems crazy to an English speaker.
I am also concerned with the fact that we have a great interpolation feature in the language, and most people building translation facilities start by adding a second interpolation system that is different from the first. Maybe we need to think harder about how to use the first one.
So, I haven’t dealt with that at all yet. I will do so eventually, but firmly believe that some of those facilities will be used 1% of the time. It might be important for that 1%. I am working on more common cases first.
Here is the string table the program presently emits, so that you can get a clue how it breaks up strings. Note that white space around an interpolation is not translated, as having translations that begun or ended with white space would be error-prone.
"Korean" => "Korean", # /home/bruce/Crystal/UserCorps/usercorps/src/pages/edit/edit_language.cr:105
# Interpolated String "Language page #{id.to_i} was deleted." at /home/bruce/Crystal/UserCorps/usercorps/src/actions/edit/language/delete_language.cr:9
"Language page" => "Language page", # Interpolated at /home/bruce/Crystal/UserCorps/usercorps/src/actions/edit/language/delete_language.cr:9
"was deleted." => "was deleted.", # Interpolated at /home/bruce/Crystal/UserCorps/usercorps/src/actions/edit/language/delete_language.cr:9
# Interpolated String "Language page #{id.to_i}, for \"#{o.tag}\", could not be deleted: #{e.message}" at /home/bruce/Crystal/UserCorps/usercorps/src/actions/edit/language/delete_language.cr:11
"Language page" => "Language page", # Interpolated at /home/bruce/Crystal/UserCorps/usercorps/src/actions/edit/language/delete_language.cr:11
", for" => ", for", # Interpolated at /home/bruce/Crystal/UserCorps/usercorps/src/actions/edit/language/delete_language.cr:11
", could not be deleted:" => ", could not be deleted:", # Interpolated at /home/bruce/Crystal/UserCorps/usercorps/src/actions/edit/language/delete_language.cr:11
# Interpolated String "The requested Language page #{id.to_i} was not found." at /home/bruce/Crystal/UserCorps/usercorps/src/actions/edit/language/delete_language.cr:14
Thanks
Bruce