Monday, February 12, 2007


This static method offers string generating function like sprintf. But, it is based on .NET string.Format().
  • {0} is required.
  • Input {0} with {1} characters or less.
This article explains why XCube took this format.

Languages have different grammar from each other. By that, message catalog often needs many translations. XCube recommends dividing words from a message. For example;
  • Name is required.
  • Message is required.
  • Input password with 32 characters or less.
  • Input email with 255 characters or less.
  • Note is required.
If I have to translate all of them..., I will forget about XOOPS and go to bars to drink beer. spritnf() enables writing as the following;
  • %s is required.
  • Input {0} with {1} or less characters.
Very well. But, you have to pay notice that this method is difficult to control order and capitalize. Japanese language has different order from English in most sentences.
  • [EN] Input %s with %s or less characters.
  • [JA] Saitei %s moji ijoude %s wo nyuuryoku sitekudasai.
When this translation is convereted by sprintf(), you look a strange message "Input 32 with password character(s) or less". Yes, the cause is difference of grammars between English and Japanese. You have just understood one of reasons that XCube took .NET format.
  • [EN] Input {0} with {1} character(s) or less.
  • [JA] Saitei {1} moji ijoude {0} wo nyuuryoku sitekudasai.
sprintf() can do the same as it, but it is not known well and it can't solve another problem as the following.
  • {0} is required.
  • Input {0} with ...
If {0} is "password", what do you set it? "Password"? or "password"?

XCube will supply modifiers to solve this problem.
  • {0:ucfirst} is required.
  • Input {0} with ...
In spritnf(), it's impossible to write modifier in string literal.

Even if a module developer does not understand the plural languages, he should use this method for contributors who try to translate.

No comments: