Details
-
Tech Debt
-
Status: Closed (View Workflow)
-
P2
-
Resolution: Done
-
None
Description
To translate messages it returns a back-end API needs to know the locale of the client.
Example message: "No item with barcode {itemBarcode} exists", for details see https://wiki.folio.org/display/I18N/How+To+translate+FOLIO
Example locale: de
Two ways to pass the current locale to a back-end API have been proposed:
accept-language HTTP header line
This is a standard HTTP header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language
The FOLIO front-end doesn't use it in favor of a configuration setting for the reasons explained in https://www.w3.org/International/questions/qa-when-lang-neg.en
The back-end modules can be extended to use the accept-language HTTP header line to determine the language they need to translate into.
lang query parameter
FOLIO defines the lang query parameter in the language RAML trait: https://github.com/folio-org/raml/blob/raml1.0/traits/language.raml
lang: description: | Requested language. Optional. [lang=en] type: string required: false default: en pattern: "[a-zA-Z]{2}"
It is declared in all RAML resource types: https://github.com/folio-org/raml/tree/raml1.0/rtypes
Therefore most back-end APIs already have the (unused) lang parameter in their implementation, for example https://github.com/folio-org/mod-circulation-storage/blob/master/src/main/java/org/folio/rest/impl/ScheduledNoticesAPI.java
The trait pattern must be extended to allow for RFC5646=BCP47 language tags that are longer than two letters, FOLIO already have front-end translations with longer tags, for example es_419, es_ES, zh_CN, zh_TW. The pattern change is a non-breaking change.
Decision log entry
https://wiki.folio.org/display/DD/Localization+parameter+for+back-end
TestRail: Results
Attachments
Issue Links
- defines
-
UXPROD-371 Enable translation of validation and other error messages that display verbatim from back end
-
- Open
-
- relates to
-
FOLIO-3351 Remove lang query parameter
-
- Closed
-