Skip to content

Latest commit

 

History

History
83 lines (55 loc) · 3.75 KB

i18n.md

File metadata and controls

83 lines (55 loc) · 3.75 KB

i18n Support

To increase familiarity with the InnerSource concept among non-English speakers, the ISC website provides pages in multiple languages. These translations are completed by volunteer contributors and are not immediately available for all pages. As a result, there may be a significant amount of content that is currently in the process of being translated. We welcome any contributions to the translation effort.

About i18n.sh script

To assist you in your translation work, we have prepared commands to run locally. Please run the i18n.sh script after reading this document.

Preparation for local editing

Pre-requisites

  • gsed command installation (*Optional for MacOS users)

    brew install gnu-sed
  • Grant execute permission You need to run the command to grant execute permission to the i18n.sh script file. This is necessary in order to run the script.

    chmod +x i18n.sh
  • Read help This command displays the help message for the i18n.sh script.

    ./i18n.sh --help/-h

Obtaining a local copy of the necessary files

In order for Hugo to properly work with pages in different languages, it is necessary to prepare all necessary files, rather than just creating translation files for certain pages. If this is not done, Hugo will return a 404 error.

However, it is not practical to maintain copies of all untranslated English files for each language in the repository. To address this issue, we use GitHub Actions to copy untranslated data from the content/en directory to the content directory of each language (content/<locale code>) when the site is updated, and placing only translated files in the repository.

While the full files are not required for the site to function properly, they may be necessary for local runs. To copy and clean untranslated files for a local run, use the following command. The copied files will be automatically added to the .gitignore file to prevent accidental commits of a large number of files.

./i18n.sh copy  

Cleaning up the local copy of the files

After completing your edits, the untranslated and unnecessary files that you copied should still be listed in the content/.gitignore file. The following set of commands will allow you to delete these files from the content directory for each language. Note: If you have completed a translation and the file path is still listed in the content/.gitignore file, your translated file will also be deleted. Be sure to update the content/.gitignore file before running the clean-up command to avoid this issue.

./i18n.sh clean 

How the code works

Despite its initial appearance of complexity, the underlying code of i18n.sh is relatively straightforward. In the event that i18n.sh experiences issues or for a deeper understanding of its function, the main components of the code can be examined individually. These individual code sections can be run independently for further analysis.

  • Create local copy for debug

    for i in de es fr it ja ru zh; do
      rsync -rv --ignore-existing content/en/ content/$i/ --log-file=content/.gitignore
      gsed -i '/total size\|file list/d' content/.gitignore
      gsed -i -E "s/^.+\s+(.+)$/$i\/\1/" content/.gitignore
    done
  • Delete local Copy for debug

    for f in $(cat content/.gitignore); do 
      rm "content/$f"
    done
    rm content/.gitignore;

Debug with GitHub Codespaces

You can start hugo server in your GitHub Codespaces terminal and see what you are editing in your browser. However, the default command appends the Port number to the URL of the build artifact and may apply localhost to the baseURL of the plugin file. Use the following command to prevent that behavior.

hugo server --appendPort=false --baseURL=/