views:

842

answers:

9

I came across a comment in some code referring to said code being "I18N safe".

What does this refer to?

+3  A: 

I18N stands for Internationalization.

Scott
+4  A: 

Internationalization. The derivation of it is "the letter I, eighteen letters, the letter N".

chaos
+3  A: 

i18n means i**nternationalizatio**n => i (18 letters) n. Code that's marked as i18n safe would be code that correctly handles non-ASCII character data (e.g. Unicode).

Rob K
And, frequently, code that keeps strings in a separate file that can be swapped out, rather than in the source code.
David Thornley
+23  A: 

I + (some 18 characters) + N = InternationalizatioN

I18N safe means that steps were taken during design and development that will facilitate Localization (L10N) at a later point.

cdonner
+1  A: 

Without any additional information, I would guess that it means the code handles text as UTF8 and is locale-aware. See this Wikipedia article for more information.

Can you be a bit more specific?

Cal Jacobson
As I'm in a pedantic mood - it could handle the text as any Unicode not just UTF8. UTF7 or UTF16 would do just as well.
MarkJ
+8  A: 

This is most often referred to a code or construct ready for I18N - i.e easily supported by common I18N techniques. For instance, the following is ready:

printf(loadResourceString("Result is %s"), result);

while the following is not:

printf("Result is " + result);

because the word order may vary in different languages. Unicode support, international date-time formatting and the like also qualify.

EDIT: added loadResourceString to make an example close to real life.

Michael Pliskin
why isn't that second one the same as the first one? Doesn't result just get pasted in in place of %s?
stimms
It does BUT the second one allows you to move the string to resources easily and rearrange words. You can then translate it as for instance "%s является результатом" (in russian) - notice different word order, you cannot use the first form directly.
Michael Pliskin
Great answer. This is EXACTLY what i18n-safe means. It usually refers to functions like this one.
Mike Sickler
Wouldn't be then "printf( fromResource , result ); " instead?
OscarRyz
@Oscar: this form is not 'I18N safe', it is one step further when a particular I18N technique is already applied. I think 'I18N safe' refers to general ideas making code more suitable for I18N. However your example qualify as well.
Michael Pliskin
I'm with Oscar on this. Neither of your examples are I18N safe - both need modification. The second one is a step on the way, but you're not world-ready yet.
MarkJ
Michael Pliskin
OK, I will give you +1 now!
MarkJ
A small point: this answer doesn't actually tell you *what* "I18N" is, just provides an example of some code that is versus some code that isn't.
RCIX
+1  A: 

I18N stands for Internationalization.

In a nutshell: I18N safe code means that it uses some kind of a lookup table for texts on the UI. For this you have to support non-ASCII encodings. This might seem to be easy, but there are some gotchas.

KovBal
+2  A: 

i18n is a shorthand for "internationalization". This was coined at DEC and actually uses lowercase i and n.

As a sidenote: L10n stands for "localization" and uses capital L to distinguish it from the lowercase i.

Anton Gogolev
+1  A: 

i18n-safe is a vague concept. It generally refers to code that will work in international environments - with different locale, keyboard, character sets etc. True i18n-safe code is hard to write.

It means that code cannot rely on:

sizeof (char) == 1

because that character could be a UTF-32 4-byte character, or a UTF-16 2-byte character, and occupy multiple bytes.

It means that code cannot rely on the length of a string equalling the number of bytes in a string. It means that code cannot rely on zero bytes in a string indicating a nul terminator. It means that code cannot simply assume ASCII encoding of text files, strings, and inputs.

Paul Beckingham