wagtail / wagtail-generic-chooser

A toolkit for custom chooser popups in Wagtail
BSD 3-Clause "New" or "Revised" License
116 stars 25 forks source link

Use proper translations for texts #9

Closed jompu closed 5 years ago

jompu commented 5 years ago

In the README.md, the examples should make translations like in the example below. This way they are translated correctly and this is also how Wagtail does them.

class MyModelChooser(AdminChooser):
    model = MyModel
    name = model._meta.verbose_name

    choose_one_text = _('Choose %s') % name
    choose_another_text = _('Choose another %s') % name
    link_to_chosen_text = _('Edit this %s') % name
gasman commented 5 years ago

Hi @jompu - thanks for the suggestion. I'd disagree on this - not all projects need translations, and we can't assume that all developers will be familiar with the _(...) method. In that situation, it would be a bad idea to introduce the concept at the same time as demonstrating how to use this library - they could be misled into thinking that _(...) is part of wagtail-generic-chooser's functionality.

If we get round to creating detailed documentation for this library (with tutorial and reference sections, rather than just a readme), then I think we could sensibly include translations as part of the tutorial.

gasman commented 5 years ago

Sorry, I think I misunderstood what you were suggesting here...

It's better to give translators complete sentences such as "Choose a person" rather than having them translate "Person" separately, as the "choose a..." text might have to change according to the following word (e.g. "a" vs "an" in English, or different genders in other languages).

The snippet chooser in Wagtail does this the "wrong" way because it's a single class dealing with many possible models, so translations have to work around that limitation (e.g. "Choose person" instead of "Choose a person"). wagtail-generic-chooser allows us to improve on this by having a separate translation for each model.