Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: RondeauG <[email protected]>
  • Loading branch information
Zeitsperre and RondeauG authored Sep 15, 2023
1 parent 6041964 commit 5bac82f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
16 changes: 8 additions & 8 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Ready to contribute? Here's how to set up `xscen` for local development.
$ mamba env create -f environment-dev.yml
$ pip install -e .

3. As xscen was installed in editable mode, we also need to compile the translation catalogs manuall:
3. As xscen was installed in editable mode, we also need to compile the translation catalogs manually:

$ make translate

Expand Down Expand Up @@ -120,13 +120,13 @@ Ready to contribute? Here's how to set up `xscen` for local development.

Translating xscen
~~~~~~~~~~~~~~~~~
If your additions to xscen play with plain text dataset attributes like "long_name" or "description", you should also provide
french translations for those fields. To manage translations, xscen uses python's `gettext` with the help of `babel`.
If your additions to xscen play with plain text attributes like "long_name" or "description", you should also provide
French translations for those fields. To manage translations, xscen uses python's `gettext` with the help of `babel`.

To update an attribute while enabling translation, use py:func:`utils.add_attr` instead of a normal set-item. For example:

.. code python
ds.attrs['description'] = "The english description"
ds.attrs['description'] = "The English description"
becomes

Expand All @@ -138,14 +138,14 @@ becomes
add_attr(ds, "description", _("English description of {a}"), a="var")
See also :py:func:`update_attr` for the special case where an attribute is updated using the previous version.
See also :py:func:`update_attr` for the special case where an attribute is updated using its previous version.

Once the code is implemented and translatable strings marked as such, we need to extract them and catalog them
in the french translation map. From the root directory of xscen, run::
Once the code is implemented and translatable strings are marked as such, we need to extract them and catalog them
in the French translation map. From the root directory of xscen, run::

$ make findfrench

Then go edit ``xscen/xscen/data/fr/LC_MESSAGES/xscen.po`` with the correct french translations. Finally, running::
Then go edit ``xscen/xscen/data/fr/LC_MESSAGES/xscen.po`` with the correct French translations. Finally, running::

$ make translate

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ dist: clean ## builds source and wheel package
install: clean ## install the package to the active Python's site-packages
python setup.py install

findfrench: ## Extract phrases and update the french translation catalog (this doesn't translate)
findfrench: ## Extract phrases and update the French translation catalog (this doesn't translate)
python setup.py extract_messages
python setup.py update_catalog -l fr

Expand Down
8 changes: 4 additions & 4 deletions docs/goodtoknow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,20 @@ What is currently not covered by either `xscen` or `xclim` is a method to resamp
Metadata translation
--------------------

xscen itself does not add many translatable attributes, but when it does it will look into xclim's options for which locales to translate them too. In a config file, activating french translation for xclim's indicators but also for xscen is done with :
xscen itself does not add many translatable attributes, but when it does, it will look into xclim's options for which locales to translate them to. In a config file, activating French translations for both xclim's indicators and xscen is done with :

.. code-block:: yaml
xclim:
metadata_locales:
- fr
Note that this only applies to attributes that are added to a dataset. Some xscen functions will only update an attribute. For example, when calculating the climatology of a variable with `long_name` `Mean temperature`, :py:func:`climatological_mean` will update the `long_name` as `30-year average of Mean temperature`. This automatic update is done for all locales available in the variable, no matter what xclim option is activated.
Note that this only applies to attributes that are added to a dataset. Some xscen functions will instead update an existing attribute. For example, when calculating the climatology of a variable with `long_name` `Mean temperature`, :py:func:`climatological_mean` will update the `long_name` as `30-year average of Mean temperature`. This automatic update is done for all locales available in the variable, no matter what xclim option is activated.

Module wide options
Module-wide options
-------------------

As seen above, it can be useful to use the "special" sections of the config file to set some module wide options. For example:
As seen above, it can be useful to use the "special" sections of the config file to set some module-wide options. For example:

.. code-block:: yaml
Expand Down
2 changes: 1 addition & 1 deletion xscen/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@


def update_attr(ds, attr, new, others=None, **fmt):
"""Format a dataset attribute referencing itself in a translatable way.
"""Format an attribute referencing itself in a translatable way.
Parameters
----------
Expand Down

0 comments on commit 5bac82f

Please sign in to comment.