oneflyingfish opened a new pull request #10249:
URL: https://github.com/apache/tvm/pull/10249


   Based on the submitted code, we can quickly and easily generate multilingual 
documents for TVM and even automatically connect to transifex.com, a well-known 
collaborative translation platform.
   
   we have successfully deployed [a project for Chinese 
documentation](https://github.com/TVMChinese/tvm). For more information, view 
the following [repositories](https://github.com/TVMChinese) directly, and this 
mentioned project is complete and has been deployed on the 
[website](https://chinese.tvm.wiki/), and our international translation is 
performed via transifex.com.
   
   0. The following work was done in the following environment:
   
      * os: https://hub.docker.com/r/tlcpack/ci-gpu
      * tx-version: 0.14.3, py 3.6, x86_64
   
   1. Based on the previous information, prepare the basic environment to 
ensure that English documents can be generated normally.
   
   2. create gettext fold, where store the `*.pot` and `*.po` files. An 
automated script has been provided and you can do this easily.
   
      ```bash
      cd docs/
      ../tests/scripts/task_python_generate_documents.sh true true false 
<language>
   
      # for example:
      ../tests/scripts/task_python_generate_documents.sh true true false zh_CN  
 # for Simplified Chinese, You can find out how to use it at the end of the 
document.
      ```
   
      The following types of `language` are supported:
   
      * bn – Bengali
      * ca – Catalan
      * cs – Czech
      * da – Danish
      * de – German
      * en – English
      * es – Spanish
      * fi – Finnish
      * fr – French
      * hr – Croatian
      * it – Italian
      * lt – Lithuanian
      * nl – Dutch
      * pl – Polish
      * pt_BR – Brazilian Portuguese
      * ru – Russian
      * sl – Slovenian
      * sv – Swedish
      * tr – Turkish
      * uk_UA – Ukrainian
      * zh_CN – Simplified Chinese
      * zh_TW – Traditional Chinese
   
   3. Translate documents directly by translating <*.po>, which is not 
recommended. We suggest a professional translation platform to implement 
multi-person collaborative translate-review. If you agree with our advice, you 
can skip this step. We will use <transifex.com> as an example to tell you how 
to deploy it.
      
      you can try to translate *.po in 
`translates/locales/<language>/LC_MESSAGES/`. Notice that 
`_staging/translates/locales` in fact is a soft-chain to `translates/locales`.
   
   4. Implement cooperative translation of <*.po> with the help of 
`transifex.com`. An automated script is also provided to help you simplify 
operations.
   
      a. config the parameters in `docs/tx_transifex.sh` firstly.
   
         ```bash
         POTDIR="translates/gettext"                  # the *.pot fold. If you 
are not sure, default is recommended
         LOCALESDIR="translates/locales"              # the *.po fold, it can 
be unexist. If you are not sure, default is recommended
         URLNAME=""                                   # you can find it in your 
project in transifex.com, the same as the share-URL suffix.
         LANGUAGE=""                                  # the target language, 
"zh_CN" (Simplified Chinese) for example
         ```
   
      b. init your transifex identity
   
         ```bash
         cd docs/
         ./tx_transifex.sh init                       # Please feel relaxed to 
kill the process(Ctrl^C) after input API token and finish verification.
         ```
   
      c. update your transifex-config, which record the relation between 
`*.pot` and `*.po`
   
         ```bash
         cd docs/
         ../tests/scripts/task_python_generate_documents.sh true true false 
<language>   # update your gettext(*.pot)
   
         ./tx_transifex.sh update                                               
    # update transifex-config
         ```
   
      d. push your changes to transifex.com
   
         ```bash
         cd docs/
         ./tx_transifex.sh push
         ```
   
      e. pull the translated-po files to locale
   
         ```bash
         cd docs/
         ./tx_transifex.sh pull
         ```
   
   5. generate the html for Chinese.
   
      We will automatically generate the 
sitemap(`$DOCS/_build/html_$LANGUAGE/*sitemap.xml`) for you, which is necessary 
if you expect your site to be detected by search engines like google.  We need 
you to specify the `ROOTURL` value in 
`docs/sitemaps/sitemap_generator/config.py`, which represents the url 
corresponding to the root of the website. If this is not helpful to you, you 
can skip this step. The default sitemap will still be generated, but it may not 
be valid.
   
      ```bash
      cd docs/
      ../tests/scripts/task_python_generate_documents.sh false false true 
<language> # the _build/html_zh_CN will be created. you can directly deploy to 
your website.
      ```
   
   6. some tips
   
      If you are just updating the translation, do the following is enough:
   
      ```bash
      cd docs/
      ./tx_transifex.sh pull  # if you use <transifex.com> and do translation 
work remotely, or you can skip this command
      ../tests/scripts/task_python_generate_documents.sh false false true 
<language>
      ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to