4 ms·
How do you handle it when you need to convert, e.g., "American woman" to "femme américaine"?
by 286c8cb04bda 14y ago
How do you handle it when you need to convert, e.g., "American woman" to "femme américaine"?
- andolanra 14y agoYou use something else. It's still just a format string, not a whole localization solution. Named arguments means it might be easier to hack together something like templates = {'en': '{adj} {noun}', 'fr': '{noun} {adj}'} print(templates['fr'].format(noun='fromage', adj='délicieux') but that's still a hack, and doesn't even come close to addressing cases like Chinese's "{adj} {counter_word[noun]} {noun}" or gender concord or any of the myriad other things you come across in practice. Edit: used 'positional' instead of 'named'.