69

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

What does this refer to?

GEOCHET
  • 21,119
  • 15
  • 74
  • 98
Redwood
  • 66,744
  • 41
  • 126
  • 187

12 Answers12

91

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
  • 37,019
  • 22
  • 105
  • 153
14

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
  • 2,352
  • 4
  • 26
  • 42
  • why isn't that second one the same as the first one? Doesn't result just get pasted in in place of %s? – stimms Feb 25 '09 at 18:04
  • 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 Feb 25 '09 at 20:14
  • Great answer. This is EXACTLY what i18n-safe means. It usually refers to functions like this one. – Mike Sickler Feb 26 '09 at 00:14
  • 1
    Wouldn't be then "printf( fromResource , result ); " instead? – OscarRyz Feb 26 '09 at 02:35
  • @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 Feb 26 '09 at 06:32
  • 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 May 06 '09 at 22:58
  • 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 Jul 03 '09 at 08:18
  • I have a doubt: would using "%S" instead of "%s" make it more i18n-safe, or it's ok to use "%s" and then make %S-changes all over the code? Just curious to know what do you guys think. – Viren May 17 '12 at 05:34
10

i18n means internationalization => 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
  • 8,757
  • 2
  • 32
  • 36
7

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

chaos
  • 122,029
  • 33
  • 303
  • 309
5

enter image description here

its a numeronym for Internationalization.

Different from Acronym, numeronym is a number based word (eg 411 = information, k9 = canine);

In code, this will normally be a folder title, that It generally refers to code that will work in international environments - with different locale, keyboard, character sets etc. ... "

Read more about it here: http://www.i18nguy.com/origini18n.html

Gel
  • 2,866
  • 2
  • 18
  • 25
5

I18N stands for Internationalization.

Scott
  • 6,411
  • 6
  • 39
  • 43
3

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
  • 113,561
  • 39
  • 200
  • 288
1

"I18N safe" coding means the code that doesn't introduce I18N bugs. I18N is a numeronym for Internationalization, where there are 18 characters between I and N.

There are multiple categories of issues related to i18n such as: Culture Format: Date Time formats(DD/MM/YY in UK and MM/DD/YY in US ), number formats, Timezone, Measuring units change from culture to culture. The data must be accepted, processed and displayed in the right format for the right culture/locale. International Characters Support: All the characters from all the different languages should be accepted, processed and displayed correctly. Localizability: The translatable strings should not be hard code. They should be externalized in resource files.

"I18N Safe" coding means that none of the above issue is introduced by the way the code is written.

Ryota Kaneko
  • 67
  • 1
  • 7
1

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
  • 2,407
  • 1
  • 26
  • 35
  • 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 May 06 '09 at 22:55
1

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,129
  • 2
  • 17
  • 31
1

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
  • 14,495
  • 5
  • 33
  • 67
0

i18n deals with - moving hard coded strings out of the code (not all should be by the way) so they can be localized/translated (localization == L10n), as others have pointed out, and also deals with - locale sensitive method, such as --methods dealing with text handling (how many words in a Japanese text is far obvious:), order/collation in different languages/writing systems, --dealing with date/time (the simplest example is showing am/pm for the US, 24 h clocks for France for instance, going to more complex calendars for specific countries), --dealing with arabic or hebrew (orientation of UI, of text, etc.), --encoding as others have pointed out --database issues it's a fairly comprehensive angle. Just dealing with "String externalization" is far from enough.

Some (software) languages are better than others in helping developers write i18n code (meaning code which will run on different locales), but it remains a software engineering responsibility.