Skip to content
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

Adding new strings for Translation #9945

Open
imajit opened this issue Jul 24, 2021 · 9 comments
Open

Adding new strings for Translation #9945

imajit opened this issue Jul 24, 2021 · 9 comments
Labels
Translation System issues which involve adding new translations, improving the translation system

Comments

@imajit
Copy link
Contributor

imajit commented Jul 24, 2021

Goal of this issue is to create FTOs for Public Lab Translation Project

Part of #9686
There are many strings that are kind of hard-coded in many views files .
For example

<a data-toggle="tooltip" title="Home" data-placement="bottom" class="navbar-brand ml-lg-5" id="brand" href="<%= root_path %>">Public Lab</a>

here you can see Public Lab is added as a string.
Ideally, we would like to have a string constant in en.yml saved as publiclab = "Public Lab" and then refer to this in all the occurrences of the string "Public Lab". There are 2 benefits of this

  • If we want to change "Public Lab" to "PUBLIC LAB" we need not find all occurrences and change it we only need to change the constant in the YAML file.
  • By adding it to the YAML file, we are also adding it to our Translation Project on Transifex. Language translators can then add translations for newly added strings and we can make Publiclab.org more genial and accessible to new and existing users and foster diversity.
    We have many strings that need to be added to the Transifex project for translation. We can do this by adding new FTOs.

Here I have tried to break all possible FTOs into 3 types

1. Adding a new string to Translation Project

For this type of FTOs, we need to add the missing string to the YAML file and then call the translation function where the sting was present.

Steps to create an FTO of this type

  1. Find a string that is hard-coded in the views files but is not there in the YAML file.
  2. Create an FTO to add the string to the YAML file and then call the translation function in the original string location.
    Let's say I want to add "Public Lab" string to the YAML file.
    • I will add it to the YAML file as:
      • publiclab: "Public Lab"
    • Now I will refer to this back in the original file using the translation function as:
      • translation('home.publiclab')
    • Done, you can check the view once to make sure the string is placed properly.
      Here is a sample FTO of this type Add "Features" string to Translation Project #9950

Note:

  1. Check if a string already exists in the YAML file before adding it.
  2. Add the new string under suitable string sets. Universal strings can be added as a separate strings. If a string is part of a view, model, or controller whose string set already exists in the YAML file then it is preferred to add it under the existing string set. For example, if I want to add a new string hello which is in a view related to the tags controller, then I can add it under tag controller string set.
    tag_controller:
  3. To call a string using the translation function, you need to call it in a hierarchical fashion, say you want to call
    welcome: "Talk page for <a href='%{url1}'>%{page}</a> | This page allows for

    the string you can call it using translation('talk.show.welcome')

2. Replacing a string with a translation function

Let's say the string "Public Lab" is stored as a string in the YAML file, but there are multiple occurrences where the string is added directly as part of the view, we can change this by calling the translation function in place of the string.

Steps to create an FTO of this type

  1. Find an occurrence of a string that is already stored in the YAML file but is directly added as a string in the view.
  2. Create an FTO to replace this string with the translation function call.
    Here is a sample FTO of this type Change "Dashboard" String to Translation Function Call #9944

3. Adding strings that are part of HTML attributes

This type of FTOs can be a bit tricky and UI checks are preferred before merging PRs.
Consider this line of code

<input aria-label="Enter Search Query" type="text" id="searchform_input" class="form-control search-query typeahead" role="search" qryType="tags" placeholder="<%= translation('layout._header.search',{},false) %>" value="<%= params[:query] %>" required>

The translation function is called inside an HTML tag here for an HTML attribute placeholder, the difference here is that the additional parameter false is also passed here.

Steps to create an FTO of this type

  1. Find a string that is hard-coded in the views files but is not there in the YAML file.
  2. Create an FTO to add the string to the YAML file and then call the translation function in the original string location.
  3. In the PR, run the changes in Gitpod and verify there are no UI breaks in the view where the changes are made. Reviewers can check this by themselves or request contributors to do so. The second option is preferred as it makes reviewing process quick and easy and also introduces Gitpod to new contributors who might find it very useful in later complex issues.
    Here is a sample FTO of this type Fix profile tag input bar #9934

Feel free to reach out if you have any doubts regarding the creation or reviewing of FTOs

@imajit imajit added the Translation System issues which involve adding new translations, improving the translation system label Jul 24, 2021
@unnati914
Copy link
Contributor

I can create a fto for this

@jywarren
Copy link
Member

@unnati914 that would be super! Perhaps check with @imajit once you've created it to give it a quick look over, then we can label it? Thank you!

@unnati914
Copy link
Contributor

surely

@subhangi2731
Copy link
Contributor

if this issue is open can I please work @TildaDares can u please assign me

@codeamic
Copy link
Contributor

Hey @TildaDares please can i work on this?

@Hydriah
Copy link

Hydriah commented Mar 27, 2022

can i create a FTO on this?

@TildaDares
Copy link
Member

Hi @codeamic, @Hydriah, yes you can create issues from this.

@Hydriah
Copy link

Hydriah commented Mar 27, 2022

@TildaDares ok thanks

@Pragati1419
Copy link

@TildaDares Can I create FTO on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Translation System issues which involve adding new translations, improving the translation system
Projects
None yet
Development

No branches or pull requests

8 participants