4 ms·
One of the most annoying things about translation is that the length of the string may change which can mess up designs and layouts. For example German strings
by shpiel 13y ago
One of the most annoying things about translation is that the length of the string may change which can mess up designs and layouts. For example German strings tend to be longer than their English equivalents. Or dealing with languages which orientation is right to left (eg. Hebrew).
- Gigablah 13y agoAnd sometimes you might have the same word or phrase in multiple locations that translate differently depending on context.
- byroot 13y agoThat's why rails do no use source locale as translation keys but a dot notation e.g. "homepage.posts.title"
- colinsidoti 13y agoAt an airbnb techtalk they stressed how this is a really annoying problem for them. They actually have a subdomain that substitutes longer than normal english strings within their design: https://xxlong.airbnb.com/ https://xxlong.airbnb.com/
- Groxx 13y agoThat's a pretty common approach. In Rails it's also not too hard to monkey patch I18n in development to e.g. double every string it returns, or throw in random UTF characters. The hard part I've encountered is that you have to think about text differently. Things that are identical in English but have different semantic meanings must be split. Plurals. Almost-never concatenating or .join(',')ing or .split()ing. It's pretty easy to write yourself into a corner unless you stick to doing it right all the time, which takes some time to learn.
- tr8n 13y agoThis is a very tricky issue. Tr8n somewhat solves it by allowing developers to specify translation key constraints for critical sections right in the code. The constraints make the translation key unique, give an indication to translators what they need to do and enforces the translators submissions. For example: <%= tr("App", :max_length => 6) %> If translators try to submit something longer than 6 chars, they will get a warning to adjust to the constraints. In Russian "App" is "Приложение". So they would have to provide something shorter or an abbreviation.
- jimeuxx 13y agoI've found this to be a bit of a nightmare with Japanese and English. Japanese DVD and CD titles often have a mix of both languages, so length becomes next to meaningless when comparing Japanese strings even against themselves. The feel of the text is also completely different, which makes it hard to balance the layout for both languages.