This PR adds localization to the backend, making it possible to translate the system to both Italian and English.
The backend deals with two types of translatable string:
Static strings, which relate to the backend business logic.
These are things such as the translation of smoothing method names (e.g. EN: centered 5-year moving average IT: media mobile centrata a 5 anni). For these, this PR introduces babel as an additional dependency and provides CLI commands to deal with the usual strategy of working with message catalogs. The typical workflow for translating these is thus to run:
arpav-ppcv translations extract
arpav-ppcv translations update
# now work on translating the files in the /translations dir
arpav-ppcv translations compile
Included in this PR is a first pass of translating these static strings to Italian, done with google translate.
Dynamic strings, which relate to the configuration that is created via the admin.
These are things such as the display name and description of coverage configurations, configuration parameters, etc. This PR enhances the relevant database tables with columns suitable for storing translation of these dynamic properties. Here is a screenshot of the admin editing screen for a configuration parameter:
Note that this PR does not include bootstrap values for providing translated names of all stock configurations - This shall be done in a subsequent PR.
This PR includes also the integration of these translated values in with the time series API endpoints, thus providing information to the frontend so that it may localize generated charts. This a sample request:
Notable things about the response snippet pasted above:
the info key contains all configuration parameters of the coverage. This is added in the spirit of #162, with the idea being that the frontend shall be able to better parse the response information with this added information
the translations key has two children: parameter_names and parameter_values. These provide appropriate translation for both the names and values of the fields present in the info key.
Also included in this PR (admittedly somewhat unrelated) is a refactor of the way time series data is fetched from the remote THREDDS server. The proposed implementation leverages anyio and httpx.AsyncClient in order to interact with THREDD's NCSS service in an async fashion. As commented in #163, this was done with the hopes of improving performance of the system.
This PR adds localization to the backend, making it possible to translate the system to both Italian and English.
The backend deals with two types of translatable string:
Static strings, which relate to the backend business logic.
These are things such as the translation of smoothing method names (e.g. EN: centered 5-year moving average IT: media mobile centrata a 5 anni). For these, this PR introduces babel as an additional dependency and provides CLI commands to deal with the usual strategy of working with message catalogs. The typical workflow for translating these is thus to run:
Included in this PR is a first pass of translating these static strings to Italian, done with google translate.
Dynamic strings, which relate to the configuration that is created via the admin.
These are things such as the display name and description of coverage configurations, configuration parameters, etc. This PR enhances the relevant database tables with columns suitable for storing translation of these dynamic properties. Here is a screenshot of the admin editing screen for a configuration parameter:
Note that this PR does not include bootstrap values for providing translated names of all stock configurations - This shall be done in a subsequent PR.
This PR includes also the integration of these translated values in with the time series API endpoints, thus providing information to the frontend so that it may localize generated charts. This a sample request:
Would return a response that now includes extensive details about the configuration and translations:
Notable things about the response snippet pasted above:
the
info
key contains all configuration parameters of the coverage. This is added in the spirit of #162, with the idea being that the frontend shall be able to better parse the response information with this added informationthe
translations
key has two children:parameter_names
andparameter_values
. These provide appropriate translation for both the names and values of the fields present in theinfo
key.Also included in this PR (admittedly somewhat unrelated) is a refactor of the way time series data is fetched from the remote THREDDS server. The proposed implementation leverages
anyio
andhttpx.AsyncClient
in order to interact with THREDD's NCSS service in an async fashion. As commented in #163, this was done with the hopes of improving performance of the system.