pressbooks/pressbooks

Contributor Type titles are not available for translation

Closed this issue · 2 comments

When rendering the 'Contributors' back matter type in a book, a list of all contributors is displayed, sorted by contributor type. However, the title of each contributor type is rendered in English, no matter what the book language has been set to. The contributor title should be localized and should display the relevant text in the book's target language. It does not, as seen here:
Screenshot from 2024-03-13 08-55-53

https://pressbooks.etsmtl.ca/modelisationcomportementacoustique/back-matter/353/

The blade template that renders this string is

<h2 class="contributor__type">{{$contributor_type['title']}}</h2>

Localization needs to be able to handle both singular and plural forms of each Contributor title (i.e. Editor/Editors, Author/Authors, Translator/Translators, etc.)

At present, the Pressbooks project .pot file does not have singular/plural strings for each of the Contributor role titles. Some exist because the word is used elsewhere in the interface, but these do not exist consistently anywhere.

I believe the issue here is how to handle translation for dynamically generated strings in Blade templates.

We discussed adding a helper method in the contributors class that uses a switch or match statement to define singular and plural forms of each of the supported contributor types:

public $valid = [
'pb_editors',
'pb_authors',
'pb_contributors',
'pb_translators',
'pb_reviewers',
'pb_illustrators',

tw77 commented

Translations from #3675 appear as expected on dev.