-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Translation workflow and documentation #1279
Comments
Thank you @PG-Momik - I think this issue has been opened in response to a request from us at IATI Support to understand the translation process. Specifically, we would like to know:
The above looks like it describes how the front end displays the translated files. My apologies for any confusion about what we were asking. |
@siwhitehouse regarding your queries: how YI extracts the source string from IATI publihsher
how these are shared with translators
how YI pull the translated files into IATI PublisherThe content of all the google doc files are correctly maintained in a spreadsheet. We then use a script that generates separate language source file for each sheet in each language as shown below: the process for review and amendment of translated filesDuring implementation there were some lines that resulted in UI inconsistency in the system, this resulted in the initial round of review of the translated text and the changes from the updated translated documents were implemented. |
Closing this issue as work on #1477 replaces it |
📖 Context:
🔵 1 : The basics
trans()
function to translate any string by accessing it though its key. Example:📑 en/source_1.php
📑 es/source_1.php
📑 fr/source_1.php
🔵 2 : Usage
We can now show translated text in an app using the complete key of said text.
📖 Implementation
🔵 1 : Overview
To modify the app's language, we use
setLocale()
method provided by Laravel.When the user selects a language option, a request is sent. The request contains the selected language which is used by the
setLocale()
method.1.1 : Folder structure
The directory containing all the language files i.e. lang directory can be found in root directory itself. All the translation file are group based on the language. We've maintained the files in the folders as follows:
1.2 : Working mechanism
Scenario 1 : Translating simple/complete text :
Desired text : "IATI Publisher helps small and medium-sized organisations publish IATI data on development and humanitarian financing and activities"
lang/*/web.php
in the keyabout_hover_text
'web.about_hover_text'
Scenario 2 : Translating dynamic text with placeholders :
Desired text : "Default-tied status updated successfully"
lang/*/responses.php
we can find the Base text : ":prefix :event successfully" in thelang/*/elements_common.php
and 'updated' fromlang/*/events.php
, thus forming the text: Default-tied-status updated successfully.lang/*/common.php
orlang/*/.elements_common.php
)events.php
)1.2.1 : Back-end Functions
For the back-end we've build helper functions that wrap around Laravel's default
trans()
function to read text from files and return translated text. In some cases these functions will use lines from different files to build a sentence accordingly.translateJsonValues()
This function translate translatable values in a json object. This function is only called when forms need to be rendered. Read 2.2 Translation for JsonSchemas for more info.
translateRequestMessage()
getLabelForAddAdditional()
translatedElement()
translateResponses()
translateElementFailed()
translateErrorHasOccurred()
translateElementDeleteError()
translateCommonError()
translateButton()
translateDoesntExist()
translateCommon()
|
1.2.2 : Front-end Function
The helper function for the frontend can be found in
translationHelper.ts
. Similar to the backend helper functions, the front end helper function also uses keys of the language files as the source.button()
event()
element()
error()
commonText()
missing()
stickyText()
webText()
adminText()
registerText() , aboutText(), iatiStandardText(), publishingChecklistText()
textFromKey()
🔵 2 : Details
2.1 : File content
Each file contains lines based on the context of the line and where the lines appear:
2.2 : Translation for JsonSchemas
All the forms in the system are generated from either
elementJsonSchema.json
ororganizationJsonSchemas
located inroot/IATI/Data/
.2.2.1 Original contents
The original contents of the json schema looked like this:
2.2.2 : New contents
In the new jsonSchemas, the values of original attributes :
label
,hover_text
,help_text
andplaceholder
of each element are replaced with complete keys that correspond to original values in theroot/lang/*/elements.php
file.When fetching any given element to generate forms, the json object are translated using the
translateJsonValues()
helper function. The new json schema looks like :The text was updated successfully, but these errors were encountered: