Git Product home page Git Product logo

aide_design_specs's Introduction

Build Status

The Translation Process

Using the Sphinx Internationalization Feature

To translate the AIDE Design Specifications Sphinx project, the Sphinx Internationalization Feature known as Internationalization can be used.

See https://aguaclara.github.io/Textbook/Textbook_Creation_Help/rst_intro.html for an introduction to RST and Sphinx

sphinx-intl is a useful tool that allows the translation process to run smoothly.

After installing sphinx-intl, configurations must be set up in conf.py such as specifications for the path and a language parameter. Once the configurations are set up, translatable messages are extracted in pot files by using the command "make gettext". The pot files will then be found in the "_build/gettext" directory. Next, po files will be generated from the pot files using "sphinx-intl update -p _build/gettext -l <source language> -l <target language>". These po files will be found in these directories:

./locale/<source language>/LC_MESSAGES/

./locale/<target language>/LC_MESSAGES/

The .po files in ./locale/<target language>/LC_MESSAGES/ can then be translated into the target language either manually or through the use of a tool such as Poedit. For manual translation, the .po files contain "msgid" string messages in the source language along with an empty "msgstr" string message directly below each one. The user can fill in the msgstr string with the translated message in the target language. Once the desired po files have been translated, a translated document can be built in the command prompt by running "make html" or any desired build command.

For detailed instructions on how to get set up and use sphinx-intl, see https://www.sphinx-doc.org/en/master/usage/advanced/intl.html#id7

What are POT and PO files?

POT files contain text extracted from the RST files and serve as a template for translations. The "msgid" messages are automatically filled in, but the "msgstr" messages contain empty strings.

PO files are copies of their corresponding POT files except that they contain the translations in the "msgstr" messages. Each language has its own PO files, so if another language is to be added, a new copy of POT files are made as PO files in which its "msgstr" messages can be filled in with a translator.

How to use Poedit

Poedit is an efficient tool to help automate the translation of po files. Once Poedit is opened, the user can follow these instructions:

  1. Navigate to the open button on the sidebar in the upper left corner.

  2. Find the desired .po file to translate within the ./locale/<target language>/LC_MESSAGES/ directory. If not already, make sure the field next to "file name" is set to either "All Translation Files" or "PO Translation Files (*.po)" :

    _images/choose_file.png
  3. If it is the first time editing that file, the following warning message will appear:

    _images/poedit_lang_warning.JPG

    select "Set language". A new window will open:

    _images/catalog_properties.JPG

    In the Language field, select the desired target language and click "OK".

  4. If the language listed next to "source text" is not the source language, continue to steps 5-6. If it is the source language, skip to step 7.

  5. Click "save" in Poedit, then open the po file in a text editor such as Atom.

  6. At the top of the file, below the first "msgid" and "msgstr" messages, "X-Generator: Poedit 2.3.1\n" can be found. Right below this, insert "X-Source-Language: <source language>\n" so that it looks like line 22 in the following example where <source language> is "es" (Spanish):

    _images/change_source_lang_ex.JPG
  7. Click on "Pre-translate" in the sidebar. Put a checkmark next to "Use online suggestions" and "Don't mark exact matches as needing work" (optional) and click "Pre-translate".

  8. Go through each translation and unmark/mark as "Needs work". Once done, click "Save" and start back at step 1 to translate a different file.

aide_design_specs's People

Contributors

fletchapin avatar dc854 avatar monroews avatar candelalencina avatar dependabot[bot] avatar

Watchers

James Cloos avatar  avatar  avatar

aide_design_specs's Issues

Create merge_index function

Most of the logic required for component-level documentation is done, but right now you have to hardcode different index files for each possible combination of components. Instead, I'd like to write a function which intelligently combines indexes so you'd only have to create one index per component (e.g. one for floc, one for sed) and then combine them automatically (currently you'd have to create one for floc, one for sed, one for sed and floc combined, etc).

Develop E2E tests for design correctness

Evaluate the possibility of including those tests in the design specifications document. Take the measurements from Onshape and calculate expert inputs for basis of design such as:

CDC: maximum coagulant dose,
LFOM: flow as a function of depth, total head loss
Flocculator: Gtheta, G, theta, velocity, total head loss, and all of those values also at 50% flow
Sed: upflow velocity in sed tank, plate settler capture velocity, effluent manifold orifice head loss, total head loss
Filter: backwash velocity, filter velocity,

Format units output by Onshape correctly

There are two main problems to solve here:

  • How do we round to the correct sig figs?
  • Can we write a function to modify units within the metric system, e.g. 0.001 meter is much more readable as 1 mm

Create 1-5 L/s Documentation

Right now we have docs for just 12-60 L/s plants. We need to create small scale plant documentation in both Spanish and English

Host website on Heroku

Website for the documentation can only be ran locally right now, we want to have it run on a Heroku server. Connect to Github so that Heroku can automatically update any Github updates on the server.

Write unit tests for parse.py

Much of our code is difficult to test because you have to build the documentation and review it by eye, but we should write unit tests for the functions in parse.py which modify files and correctly handle units. This will ensure that there are no regressions as we add more functionality

ENH: Deploy Heroku site through GitHub actions

Use Case

When a deploy build is triggered, the heroku website could be packaged and deployed following these instructions.

Solution

When a tagged version is pushed to aide_design_specs or when pushes are made to the stable branch (up to the implementer which solution is preferred, here is are examples of tagged versions and stable branches starting workflows.

A GitHub action can be configured to deploy to Heroku. A Heroku token will likely have to be added to the repo secrets for this to work.

Alternatives

The website is currently deployed manually from the command line by AIDE team members. An alternative is to mimic this deployment in a custom GH action.

From the above instructions.

heroku create --buildpack https://github.com/Thermondo/heroku-buildpack-tex.git
heroku buildpacks:add heroku/python
git push heroku master
git push heroku deploy:master

ENH: Add validation report to website

Use Case

When the user downloads the documentation for their AguaClara plant or component model they can also validate the component and download a validation report.

Solution

Since aide-validation was released on PyPi, I'm hoping to import the validation functions and call them as part of the documentation building workflow so the user has to enter the link only once to get both validation and documentation.

Alternatives

aide_validation has a working GUI, so it should be simple enough to create a second section of the current design specs website. The downside of this is the user having to enter the same link in two places to get a full report.

ENH: Get the version to update appropriately

Use Case

On the title page of the PDF or header of the HTML documentation there is a version listed, and right now it always defaults to version EXPERIMENTAL.

Solution

The version is defined here in conf.py. The os.getenv call should be fixed to figure out the version in a different way since Travis is no longer being used, TRAVIS_TAG is undefined.

Alternatives

The version isn't super important so letting it default to EXPERIMENTAL is probably fine.

Create logic for component-level documentation

For example, if just a flocculator component was designed in Onshape, we'd want just the flocculator section of the docs to be built. This will require smart selection of .rst files (and perhaps auto-generation of the index file to avoid duplicating it)

Switch source language to English

Since English is more widely used internationally, Monroe suggested we switch the source language to that and translate into Spanish using the already working Sphinx internationalization

ENH: Only include supported language and file types based on report type selection

Use Case

When selecting what kind of report for the website to produce, some file types and languages are only supported by certain report types. For example, the Design Specs can be output in PDF or HTML form, but the validation report can only be a PDF. See this PR and associated issue.

Solution

Ideally, the user selects Report Type first before the Language and File Type options are displayed. This way, only file types supported by the selected report will be displayed in the dropdown.

Alternatives

To avoid this, we put all permutations into a single dropdown, e.g. Design Specs - PDF (Spanish). This single list approach is less user friendly and will grow quite rapidly as new languages or file types are added, so ideally it should be replaced.

BUG: Table of Contents appears in Spanish regardless of language selected

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of aide_design_specs.


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Description

Still need to verify if this is an existing bug or used to work and just broke, but the index of the Sphinx build isn't getting translated. All other pages appear in the correct language, but the table of contents (ToC) are always in Spanish

Expected Behavior

The language of the ToC should be the same as the rest of the document (whatever the user selected in the dropdown)

Reproduction

From the master branch, run python manage.py runserver. Navigate to the website (127.0.0.1:8000) and select an English language document using this URL: https://cad.onshape.com/documents/5333641b7d4a50ff8c28cd56/w/072d4d899d5d5e4d3a69afbd/e/299e5364fbc39e64dab2ca67

You should see that most of the document is in English but the ToC is still in Spanish.

Environment

Environment is the standard created by pip install -r requirements.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.