Page History
...
When new keys are introduced, TODO messages are automatically added to the catalogs of other languages.
Translation files (.po)
Comments - #
All lines in the translation files that start with # are comments, either aimed at helping developers or helping translators.
#: at the start of a line is a source reference, aimed at making it clear where in the source code this message IS or WAS used. Because the original po files were migrated from another, json based format, the old JSON keys have been added as source references, to make it clear where the message originally came from in the previous format.
Normal key / msgid examples
For most keys that need to be translated, the English original is part of the DSpace Angular source code. This original is then used as the msgid.
As a translator, you add the translation into the msgstr variable.
As demonstrated in the example below, you are required to wrap your translation in double quotes.
Code Block | ||||
---|---|---|---|---|
| ||||
#: .item.edit.withdraw.description
msgid "Are you sure this item should be withdrawn from the archive?"
msgstr "Ben je zeker dat je dit item wil terugtrekken uit het archief?" |
Following multi-line example shows that both the original key, as well as the translation, can be split over multiple lines.
Code Block | ||||
---|---|---|---|---|
| ||||
#: .submission.sections.upload.info
msgid ""
"Here you will find all the files currently in the item. You can update the "
"file metadata and access conditions or <strong>upload additional files just "
"dragging & dropping them everywhere in the page</strong>"
msgstr ""
"Hier vind je alle bestanden momenteel opgeladen in het item. Je kan hier de "
"bestands metadata en toegangsvoorwaarden aanpassen. Je kan ook <strong>extra"
"bestanden toevoegen door ze eender waar naar de pagina te slepen</strong>" |
Because double quote is the special character that starts or ends a message, you need to prefix double quotes with \ if you want them to appear in the actual message.
Likewise, as the previous just explained that \ can be used to escape characters, you also need to escape \ itself if you want it to appear in the message.
Code Block | ||||
---|---|---|---|---|
| ||||
#: .submission.workflow.generic.delete-help
msgid ""
"If you would to discard this item, select \"Delete\". You will then be "
"asked to confirm it."
msgstr ""
"If you would to discard this item, select \"Delete\". You will then be "
"asked to confirm it." |
Dynamic key example
In parts of the DSpace Angular code, a list of very similar objects is being built and displayed in the user interface, for example, the search filters.
These similar objects all need different labels in the user interface:
- search.filters.filter.author.head
- search.filters.filter.dateissued.head
- ...
Contrary to the normal keys that are discussed higher on this page, they keys are dynamically built in the code, meaning that the developer has no opportunity to put the English string into the code, unless he or she would hard-code a static list of those similar objects. If this sounds too abstract, look at the snippet of angular component code that puts these search filters in the page:
Code Block | ||
---|---|---|
| ||
<h5 class="d-inline-block mb-0">{{'search.filters.filter.' + filter.name + '.head'| translate}}</h5> |
So to deal with these kinds of occurences, we are currently still using the (old) en.json key entries for those type of messages, in the en.po file, for example:
Code Block | ||
---|---|---|
| ||
#. ENGLISH KEY: "Author"
#: .search.filters.filter.author.head
msgid "search.filters.filter.author.head"
msgstr "Author" |
Notice how here, that the English translation is also added into the comments, because msgid needs to hold the key in order for the translation to work.
The Angular DSpace 7 message catalog (dspace.pot)
The format of the dspace.pot catalog file, is very similar to the format of the translations.
The main difference is that this file does not contain actual translated strings (msgstr), because it serves as the authoritative catalog of the source messages, without translations.
Background reading
...
Code Block | ||
---|---|---|
| ||
app/+community-page/delete-community-page/delete-community-page.component.html:5: <h2 id="header" class="border-bottom pb-2">{{ 'community.delete.head' | translate app/+community-page/delete-community-page/delete-community-page.component.html:7: <p class="pb-2">{{ 'community.delete.text' | translate:{ dso: dso.name } }}</p> app/+community-page/delete-community-page/delete-community-page.component.html:12: <button class="btn btn-primary" (click)="onCancel(dso)">{{'community.delete.cancel' | translate}} app/+community-page/edit-community-page/edit-community-page.component.html:4: <h2 id="header" class="border-bottom pb-2">{{ 'community.edit.head' | translate }}</h2> |