turquoiseowl / i18n

Smart internationalization for ASP.NET
Other
556 stars 156 forks source link

formatting dynamic value for translation #256

Closed phat1234 closed 8 years ago

phat1234 commented 8 years ago

Hello I have string like this :" {0} Win Loss Details" and i tried [[[%0 Win Loss Details|||{0}|||]]] web.config

but it does not work.

any idea for this Thanks.

turquoiseowl commented 8 years ago

In what context? string.Format?

phat1234 commented 8 years ago

Yes I am on my way now ex: if I have String.format("{0} Win Loss Details", type); -> Type ("Admin", "ShareHolder",....) so in the file translate, i put in for all of them "Admin Win Loss Details" "ShareHolder Win Loss Details" ... But this way does not good.That's so complicated. any best idea to do that Thanks.

turquoiseowl commented 8 years ago

Hmm, not too sure what you're asking. You can set type first, e.g.

    string type = isAdmin ? "[[[Admin]]]" : "[[[ShareHolder]]]"; /// or whatever

then build your localizable formatted string:

    string output = string.Format("[[[%0 Win Loss Details|||{0}]]]", type);

The above would result in 3 PO messages in the PO files.

phat1234 commented 8 years ago

yes, I understood. thanks for your help