Internationalization for snips
The problem
I don't mind writing stuff in english, but since my native language is german I also like to write in german from time to time.
For my personal SnipSnap running at home I have the problem that I have friends that
- don't speak english, and some that
- don't speak german.
Solutions
Now, what should I do if I want to, say, post some stories and images from my last vacation on my SnipSnap?
I could:
- Simply add german and english texts in all snips, letting the reader sort it out.
- Set up two instances of SnipSnap, one for german native speakers and one with english as main language (I wouldn't even dream of wanting to synchronize these).
- Use a naming convention for snips, like <foo>-de and <foo>-en (similar to Java resource bundles). SnipSnap already does this for comments.
- Use namespaces for i18n, see phobias note about special namespaces in this context.
- Try to use labels to achieve this, maybe in combination with namespaces.
- Provide "inline" snip support for i18n, maybe with use of macros.
I'll quickly sketch some of the pros/cons (in my opinion) below.
Namespaces
I think using namespaces would provide the most powerful solution here. Using something like "/mysnip" for the default language and "/mysnip/i18n/de" for the german version would be fine.
That is if I wanted to use SnipSnap for something where the focus also lies on internationalization. For use in a fast changing environment where users add ideas, post comments, etc. this is probably overkill and hard to maintain.
The advantage on the other hand is a clear separation and I could always "extract" one language part, automatically check what still needs to be translated, maybe even employ tools like
Babel Fish to automatically translate untranslated stuff.
Handling of requests wouldn't be simple anymore though, if a user requests "mysnip" he should get "mysnip/i18n/de" automatically if his language preference is german. A link at the top of the page should indicate that there are also other language versions available and last but not least input should also provide support for multiple languages.
=> Sounds like a fairly complicated solution.
Naming pattern for snips
A simple straightforward solution that could be implemented similar to comments.
The pros and cons are probably the same as for the namespaces solution sketched above, while it tastes a bit more like a "hack". :-)
Inline internationalization
That would be a very straightforward and simple way to get i18n. Consider the following macros:
{i18n}
{lang:de}
Deutscher Teil.
{lang:de}
{lang:en}
English part.
{lang:en}
{i18n}Like this I could enter everything in one place and still render the preferred language for a user. Everything enclosed in a {i18n} block only gets rendered once, namely in the best suited language. This way I could also mix multi-language stuff in one snip.
Other solutions?
Any comments, ideas?!?