The post is interesting as it exposes the problem statement. Unfortunately, I expected from a Shopify Engineering blog that it would provide solutions to this problem like a JS library for i18n. Disclaimer: As I'm not a frontend developer I'm not familiar with the ecosystem solutions.
Lessons From Linguistics: i18n Best Practices for Front-End Developers
11–20 of 102 posts
Re: Lessons From Linguistics: i18n Best Practices for Front-End Developers
#12Re: Lessons From Linguistics: i18n Best Practices for Front-End Developers
#13This is a good article, though as someone who prefers references/tables to prose for technical topics, the real find for me was the link out to the Unicode CLDR project (which sadly contains a LOT of broken links right now due to a data migration effort but I'll bookmark it & hopefully it'll be navigable in future). As someone with a Polish partner, who also fluently speaks my own weird minority local language (Irish…
Re: Lessons From Linguistics: i18n Best Practices for Front-End Developers
#14I never display a quoted string. I always use Apple's tokenization (or create my own, if doing server code).
Apple has terrific support for localization, which puts the onus on us, to honor it. I have some basic extensions that I use to support localization in my coding[0-2], but there's also just stuff I need to keep in mind, all the time.
There has been discussion of how to deal with things like word order in different languages. For example, in Germanic languages, the modifier usually precedes the subject, while in Romance languages, it tends to be the opposite.
Thankfully, Apple supports the "$" format for sprintf strings[3], so we can do stuff like this:
import Foundation
let localizationAssets = [
(format: "The %1$@ %2$@", modifier: "white", subject: "horse"),
(format: "Le %2$@ %1$@", modifier: "blanc", subject: "cheval")
]
func localizedHorse(_ inLocalization: Int) -> String {
String(
format: localizationAssets[inLocalization].format,
localizationAssets[inLocalization].modifier,
localizationAssets[inLocalization].subject
)
}
// English (Prints "The white horse")
print(localizedHorse(0))
// French (Prints "Le cheval blanc")
print(localizedHorse(1))
[0] https://github.com/RiftValleySoftware/RVS_Generic_Swift_Tool...[1] https://github.com/RiftValleySoftware/RVS_Generic_Swift_Tool...
[2] https://github.com/RiftValleySoftware/RVS_Generic_Swift_Tool...
[3] https://developer.apple.com/library/archive/documentation/Co...
Re: Lessons From Linguistics: i18n Best Practices for Front-End Developers
#15Is there some kind of Auto-i18n where the function sends a request to a server if there is no localization available? The server could in turn request a translation from a service and add it to the localization files
Re: Lessons From Linguistics: i18n Best Practices for Front-End Developers
#16Is there some kind of Auto-i18n where the function sends a request to a server if there is no localization available? The server could in turn request a translation from a service and add it to the localization files
Though you need a backend to save this and manage translations. The maintainer of that library, locize, business model is to provide such a service.
Re: Lessons From Linguistics: i18n Best Practices for Front-End Developers
#17Don't forget Right-To-Left languages, that also affects how UI elements are arranged (position within the page) and rendered (input widgets like sliders get reversed).
Re: Lessons From Linguistics: i18n Best Practices for Front-End Developers
#18I've found that I need to support localization from the very start. I never display a quoted string. I always use Apple's tokenization (or create my own, if doing server code). Apple has terrific support for localization, which puts the onus on us, to honor it. I have some basic extensions that I use to support localization in my coding[0-2], but there's also just stuff I need to keep in mind, all the time. There has…
Re: Lessons From Linguistics: i18n Best Practices for Front-End Developers
#19This is simply not true. Since English and Dutch are both Germanic languages they largely work the same way. Saying "Toegevoegd: 1 januari" would be just fine. By using "1 januari toevoegd" you're syntactically changing the sentence.
Re: Lessons From Linguistics: i18n Best Practices for Front-End Developers
#20I've found that I need to support localization from the very start. I never display a quoted string. I always use Apple's tokenization (or create my own, if doing server code). Apple has terrific support for localization, which puts the onus on us, to honor it. I have some basic extensions that I use to support localization in my coding[0-2], but there's also just stuff I need to keep in mind, all the time. There has…
The code example should rather be an example of what not to do. This method of concatenating different parts of sentences would fall short for any language where the adjective and noun change the form depending on each other and the context (ex. cases). Most Slavic languages make heavy use of this concept. The solution is to just have the full sentence as a single string and let the translation team write it out in i…
Of course, you are correct, but we don't always have the luxury of being able to hand an entire string to a localization team, and some programmatic interpretation often needs to be done.
The best way to deal with it, is to design code that allows entire sentences to be handed to translators (I do that, most of the time).
The other advantage of writing localized content, is that it can be easily modified by non-engineers, like marketing folks. Talking points and corporate glossaries are important. Even if we don't plan to localize, it doesn't hurt to use localization tokenized content.