Translating my (and maybe even other's) SailfishOS apps

December 15, 2024 · View on GitHub

Read this before translating my apps. Even if you translated other apps, there are some pitfalls here, and a lot of people wasted their time translating what is not needed, so please at least read step 5.

The most important aspect is to translate Opal modules here, and keep the translations unfinished in the .ts file.

When following this instruction, make sure that you should replace appname with actual app name. For example, for Sailcord it is harbour-saildiscord.

  1. Fork the repo from GitHub UI. When creating the fork, select the "Copy the main branch only" checkmark. Only needed once
  2. If required, click on "Sync fork" on your fork.
  3. (Optional) You can create a new branch with your translation by selecting the main branch you forked -> "View all branches" -> "New branch" and typing whatever branch name you want. I recommend patch-n where n is 1 for the first branch, 2 for the second, etc. Then go to your branch on the GitHub.
  4. Go to folder translations. If it doesn't exist, go to folder appname -> translations.
    • If there is a file with your language code, click on it and select the edit icon
    • If not:
      1. Click on harbour-appname.ts file
      2. Select copy icon (Copy raw file)
      3. Go back, click Add file -> Create new file
      4. Enter harbour-appname-xx.ts replacing xx with your language code as the name. For example, ru for Russian
      5. Paste the copied file in the new file's contents
  5. Make your changes. Note that:
    • Do not update Opal modules translations. They include About page translations, and their context name is prefixed with Opal.. Do it here instead. When editing harbour-appname.ts, just skip them. An example:

      <context>
         <name>Opal.About</name>
         ...
      </context>
      
    • When translating a string, read its comments if available. They include things which describe the context of the string (where it is used).

    • %1, %2, %3, etc. parts will be replaced with additional data

    • Parts starting with & and ending with ; mean that they'll be replaced with special characters. You can check the full list by googling "html entities list". The most common are:

      coderendered
      &lt;>
      &gt;<
      &amp&
      &quot;"
      &apos;'
    • To translate a string, modify the lines starting with <translation. Remove type="unfinished" parts and insert your translation between > and < characters. As the source use the lines starting with <source>, which are above the actual translation. Example:

      Original:
      
          <message>
            <location filename="../qml/pages/FirstPage.qml" line="62"/>
            <location filename="../qml/pages/LoginDialog.qml" line="20"/>
            <source>About</source>
            <comment>App</comment>
            <translation type="unfinished"></translation>
      </message>
      
      Modified:
      
      <message>
            <location filename="../qml/pages/FirstPage.qml" line="62"/>
            <location filename="../qml/pages/LoginDialog.qml" line="20"/>
            <source>About</source>
            <comment>App</comment>
            <translation>О программе</translation>
      </message>
      
  6. Click on Commit changes -> Commit changes. Leave the commit options default
  7. Go to the main page of your fork, select your branch if you created it
  8. Click on Contribute -> Open pull request -> Create pull request