June 14, 2002 Re: Internationalization | ||||
---|---|---|---|---|
| ||||
Posted in reply to Burton Radons | >> Is there any such support in D? > > Since va_list gives no information about the type, size, or number of parameters, indexed conversion specifiers would either have to depend upon some beezarre format string analysis to figure out what the parameters are, a prefixed dictionary, as in "ssds:This %s is %:2d the %:3s format %:1s text", or preprocessing, as in gettext. All three solutions are bug-inducing, and the first requires that all parameters to the highest one indexed get mentioned in the format string. > > One stone can kill this bird and many others - I described a solution that fixes the problem more readily than generic objects (which don't address others that this solution does, such as constructing and destructing arguments to normal functions) in the "float -> double conversion" thread in early May. Then, as with Python, most of the time you'd just use %s regardless of the type. > > [snip] > Yes ! There are many problems with message output ! But theare are also the necessity of a standart way of tranlating a program. I know the program must be projected with internationalization in mind. But without simple conventions, each program will have a form of translation. And the state of D translation will be the same of C. For now, maybe the resouce/constants/replace_token could be the best. I dont understand why the formal meaning of double quotes and single quotes could be problematic. There are some reason ? |
June 18, 2002 Re: Internationalization | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew Wilson | "Matthew Wilson" <matthew@thedjournal.com> wrote in message news:aebaa2$1ctn$1@digitaldaemon.com... > One (and it pains me to say so) good thing about C# is that they have an alternate printf syntax, such as > > if(language == 1) > { > fmtStr = "This {0} is {2} the {3} format {1} text"; > } > else > { > fmtStr = "Bonjour {1} nous {0} sommes {3} discarde {2} le cup > de monde"; // Spot the linguist! > } The version statement in D can serve to handle things like this. |
June 19, 2002 Re: Internationalization | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | On Tue, 18 Jun 2002 15:47:54 -0700 "Walter" <walter@digitalmars.com> wrote:
> "Matthew Wilson" <matthew@thedjournal.com> wrote in message news:aebaa2$1ctn$1@digitaldaemon.com...
>> One (and it pains me to say so) good thing about C# is that they have an alternate printf syntax, such as
>>
>> if(language == 1)
>> {
>> fmtStr = "This {0} is {2} the {3} format {1} text";
>> }
>> else
>> {
>> fmtStr = "Bonjour {1} nous {0} sommes {3} discarde {2} le
> cup
>> de monde"; // Spot the linguist!
>> }
>
> The version statement in D can serve to handle things like this.
As long as D doesn't have a printing (or formatting) function which allows
to put arguments in arbitrary order, version() would do nothing.
|
June 19, 2002 Re: Internationalization | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | Pavel Minayev wrote:
> On Tue, 18 Jun 2002 15:47:54 -0700 "Walter" <walter@digitalmars.com> wrote:
>
>
>>"Matthew Wilson" <matthew@thedjournal.com> wrote in message
>>news:aebaa2$1ctn$1@digitaldaemon.com...
>>
>>>One (and it pains me to say so) good thing about C# is that they have an
>>>alternate printf syntax, such as
>>>
>>> if(language == 1)
>>> {
>>> fmtStr = "This {0} is {2} the {3} format {1} text";
>>> }
>>> else
>>> {
>>> fmtStr = "Bonjour {1} nous {0} sommes {3} discarde {2} le
>>
>>cup
>>
>>>de monde"; // Spot the linguist!
>>> }
>>
>>The version statement in D can serve to handle things like this.
>
> As long as D doesn't have a printing (or formatting) function which allows
> to put arguments in arbitrary order, version() would do nothing.
This could be hacked around. The original string is in normal printf format, such as: "%s(%08X): Expected data to be in the range (0 <= %d < %d)". Translations start with "%1(%2): Expected data to be in the range (0 <= %3 < %4)" and can move them around. During translation, you take the original formatting string and convert it into "%s\0%08X\0%d\0%d", take the result, split it up, and then format the translated string with correct indices using a special function.
|
June 19, 2002 Re: Internationalization | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | "Walter" <walter@digitalmars.com> wrote in news:aeoeoo$92j$1 @digitaldaemon.com:
>
> "Matthew Wilson" <matthew@thedjournal.com> wrote in message news:aebaa2$1ctn$1@digitaldaemon.com...
>> One (and it pains me to say so) good thing about C# is that they have an alternate printf syntax, such as
>>
>> if(language == 1)
>> {
>> fmtStr = "This {0} is {2} the {3} format {1} text";
>> }
>> else
>> {
>> fmtStr = "Bonjour {1} nous {0} sommes {3} discarde {2} le
> cup
>> de monde"; // Spot the linguist!
>> }
>
> The version statement in D can serve to handle things like this.
>
>
Yes. In some cases this could be used.
But if breaks some things?
o Translator dont need know programming to translate.
o All strings will be in ALL files and not centralized in one
o Source is greather and dificult to read
A simple program which parses the input D file and modifies it replacing the strings with constants and put all strings in another file will kill a majority of problems. This program is not to dificult for write, but for this is needed a convention saying what is a resource string and what is not translatable.
For a solution like this I have proposed the convention:
"foo" is a normal string.
'foo' is a string used in translation. ( or the inverse, I dont remember )
Maybe a better solution for using it with versioning could be :
module messages;
version(language == pt_BR){
import messages_pt_BR;
}
else
version(language == pt_PT)}{
import messages_pt;
}
else
import messages_en;
A standart table of constants for versioning and languages could be valuable in such cases.
|
June 19, 2002 Re: Internationalization | ||||
---|---|---|---|---|
| ||||
Posted in reply to Juarez Rudsatz | On Wed, 19 Jun 2002 16:47:10 +0000 (UTC) Juarez Rudsatz <juarez@correio.com> wrote:
> For a solution like this I have proposed the convention:
>
> "foo" is a normal string.
> 'foo' is a string used in translation. ( or the inverse, I dont remember )
Don't forget that D already differentiates single and double quotes: strings enclosed in the former don't support escape-characters.
|
June 19, 2002 Re: Internationalization | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | Pavel Minayev <evilone@omen.ru> wrote in news:CFN37426909090787@news.digitalmars.com: > > Don't forget that D already differentiates single and double quotes: strings enclosed in the former don't support escape-characters. > I can't distigue what is the best choice. Maybe the second because the string can contain newlines and tabs. But there are problems when writing chars like "\\". |
June 21, 2002 Re: Internationalization | ||||
---|---|---|---|---|
| ||||
Posted in reply to Juarez Rudsatz | "Juarez Rudsatz" <juarez@correio.com> wrote in message news:Xns92328D38A1172juarezcom@63.105.9.61... > A simple program which parses the input D file and modifies it replacing the strings with constants and put all strings in another file will kill a majority of problems. This program is not to dificult for write, but for this is needed a convention saying what is a resource string and what is not translatable. > I've developed the program of this kind to make localization of my Russian DOSX program into Chinese. It considered strings as localizable which started with L" , while starting with " were considered as internal name, filenames and so on. The utility replaced L"..." strings with elements of wchar_t *Strs[];, and really they were placed onto external file. Special application has been done by me in order to edit (localize) strings. With it Chinese engineers translated all information from Russian into Chinese themselves. The problem which arises when replacing L"..." with Strs[NNN] is declarations like this: wchar_t msg[10] = L"Dummy". The same applies to "wchar_t [N]"-like members of structs, when initializing struct with = { ..., L"Dummy", ... }; I had to manually convert these declarations into wchar_t msg[10]; wcscpy ( msg, L"Dummy" ); before running utility. Nic Tiger. |
Copyright © 1999-2021 by the D Language Foundation