Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Make yourself familiar with the new json5 catalog of DSpace messages

...

Widget Connector
width800
urlhttps://www.youtube.com/watch?v=zQ199ywN_kY

...

2020-

...

05-18 Development status

This documentation page has been updated to reflect that the language catalogs have moved from /resources/i18n to /src/assets/i18n and that sync-i18n-files.js has now become a typescript file.

Instructions to start the script have been updated.

Early DSpace 7 Documentation is now available at Multilingual Support

Pull Request with placeholder catalogs for all languages we had present in XMLUI: https://github.com/DSpace/dspace-angular/pull/521

TODO update the documentation at Localization L10n

Volunteer!

Please list your name, email address alongside any of the languages to which you wish to contribute. Also feel free to join the channel #translation on the DuraSpace DSpace Slack for assistance and discussion around DSpace 7 translations. 

Dutch (nl.json5)

Bram Luyten - bram@atmire.comMarina Muilwijk 

German (de.json5)

Claudia Jürgen - claudia.juergen@tu-dortmund.de 

Spanish (es.json5)

Maria Fernanda Ruiz

Eva Braña Arvo Consultores for Version 7.3 )

Emilio Lorenzo (Arvo Consultores for Version 7.3 )

Brazilian Portuguese (pt-BR.json5)

Vítor Silvério Rodrigues

French (fr.json5)

David Cavrenne [Atmire]

Marie-Hélène Vézina

Finnish (fi.json5)

Reeta Kuuskoski

Latvian (lv.json5)

Denijs Balodis

Polish (pl.json5)

Michał Dykas  (PCG Academia)

Translator documentation

The authoritative English master file (en.json5)

The catalogs can be found in resources src/assets/i18n

Code Block
titleen.json5 example section
"submission.workflow.tasks.claimed.reject.reason.submit": "Reject item",

"submission.workflow.tasks.claimed.reject.reason.title": "Reason",

"submission.workflow.tasks.claimed.reject.submit": "Reject",

"submission.workflow.tasks.claimed.reject_help": "If you have reviewed the item and found it is <strong>not</strong> suitable for inclusion in the collection, select \"Reject\".  You will then be asked to enter a message indicating why the item is unsuitable, and whether the submitter should change something and resubmit.",

...

2. Preload your new catalog with all the messages in the en.json5 catalog by executing the sync-i18n-files.js ts script, for which you can find more detailed documentation lower on this page. Assuming you are in /src/resourcesassets/i18n, you can execute:

Code Block
yarn run sync-i18n -s en.json5 -i -t fr.json5

or

Code Block
ts-node --project ../../../tsconfig.ts-node.json ../../../scripts/sync-i18n-files.jsts -s en.json5 -i -t fr.json5

where en.json5 is the "source" language file where the original keys will be retrieved, and fr.json5 is the catalog of the new language for which you want to start a translation. 

The file should now be filled with all of the English messages, that are now present both as comments, as well as message, for you to translate.

...

4. Activate the new language in environment./src/config/default.js-app-config.ts (look for the "LangConfig[]" array)

Code Block
{languages: LangConfig[] = [
  ...
  { code: 'nl',
    label: 'Nederlands',
    active: true},
}
  ...
];

Where code is the two letter code for your language, also used as the filename for your translated catalog. 

...

Code Block
titlejson5 validate
yarn json5 --validate ./src/resourcesassets/i18n/es.json5

Examples of possible errors you might get:

...

This particular mistake occurred where there was an extra space between \ and " in the \" combination used to escape the "

Checking your files syntax via "lint"

Lint is a tool we use to ensure files are correctly formatted, and have no extra characters (e.g. extra spaces at the end of each line can make the file large in size, which take longer for users to download).  This simple command will check your file's syntax (run this from the root folder):

Code Block
yarn lint --lint-file-patterns src/assets/i18n/*.json5

(NOTE: Warnings shown by lint can be ignored.  Errors are the only thing that require cleanup)


If that throws errors, most can be automatically cleaned up by adding "--fix" to the same command:

Code Block
yarn lint --lint-file-patterns src/assets/i18n/*.json5 --fix


NOTE: currently, "--fix" is unable to add missing commas on the end of each line.  Every new line (which is not a comment) MUST end in a comma.  However, if you have a missing comma, you'll see an error like this:

Code Block
# This error is a sign that you have a missing comma on the line just BEFORE [some translation key]
Parsing error: Unexpected token [some translation key]


Your first translation pull request!

Once you have your first translation, in your dspace-angular repository on your account on Github, you can send these translations in as a pull request. Following screenshots provide clarification:

Overview of your branches, where you can start the pull request. This is at https://github.com/bram-atmire/dspace-angular/branches where "bram-atmire" is changed by your own user name.

Image Added

When you make a pull request, make sure it goes to the "base repository" DSpace/dspace-angular, into the master branch

Image Added

If you experience any difficulties with this, people are ready to help you on #translation in the DuraSpace slack

Developer i18n How-to

When you create new keys, update existing keys or the meaning of existing messages, keep the following in mind.

...

Please run the node script: /scripts/sync-i18n-files.jsts.

There are two ways to run this script:

  • yarn run sync-i18n
  • ts-node --project ../../../tsconfig.ts-node.json ../../../scripts/sync-i18n-files.ts ==> assuming that you execute this while you are in /src/assets/i18n

The results of your changes will be reflected in the catalogs of the other languages, so translators can pick up the work to:

...

By default, the execution of sync-i18n-files.js ts will:

  • look at en.json5 as the authoritative source file
  • will look at all catalogs present in /src/resourcesassets/i18n/ as target files to sync up with the latest changes in source.
  • will execute these changes in-place, meaning that no backup etc is taken of the translation before the sync

...