Skip to content

Commit

Permalink
Add in LaTeX form.
Browse files Browse the repository at this point in the history
  • Loading branch information
HansOlsson committed Feb 18, 2022
1 parent 3443168 commit ce3d00e
Showing 1 changed file with 111 additions and 0 deletions.
111 changes: 111 additions & 0 deletions chapters/packages.tex
Expand Up @@ -326,3 +326,114 @@ \section{External resources}\label{external-resources}
\filename{modelica://Modelica/Mechanics/C.jpg} is illegal.
The references \filename{modelica://Modelica.Mechanics/C.jpg} and \filename{modelica://Modelica/C.jpg} must also refer to two distinct resources.
\end{example}

\section{Multilingual Descriptions}\label{multilingual-descriptions}

\begin{nonnormative}
Descriptive texts in a model or library are usually formulated in English.
To support users who are not so familiar with this, a Modelica tool can support the translation of these texts into any language.
This should be done using external files, so that no modification of the actual Modelica text is required.
\end{nonnormative}

The files to support translation must be provided by the developer of the library.
They must be stored in a subdirectory of the \filename{Resources} directory of the library with the name \filename{Language}.

Two kind of files have to be provided:
\begin{enumerate}
\item template file \filename{<LibraryName>.pot}.
It contains all necessary information to translate all descriptions, but no translations.
The pattern \filename{<LibraryName>} denotes the toplevel class name of the library.
\item one file for each supported language with the name \filename{<LibraryName>.<language>.po}.
This file is a copy of the associated template file, but extended with the translations in the specified language.
The pattern \filename{<language>} stands for the ISO 639 language code, e.g. de or en.
\end{enumerate}

The files consist of a header and a body.
All text strings are in double quotes and encoded with UTF-8 characters.
Comments start with an \lstinline!#! and are continued until the end of line.
Spaces outside strings are ignored and used as separators.
The detailed format of these files is described in \href{https://www.gnu.org/software/gettext/manual/gettext.pdf}{GNU gettext}.

The header is marked with an empty msgid entry and looks like this:
\begin{lstlisting}
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-03-15 10:52+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
\end{lstlisting}
All general terms in the header should be replaced by specific information.

In the body, directly following the header, for each descriptive text there is an entry of the form
\begin{lstlisting}
#: <file name>:<line number>
msgctxt "<context identifier>"
msgid "<descriptive text>"
msgstr "<translation>"
\end{lstlisting}
Only the keywords \lstinline!msgctxt!, \lstinline!msgid! and \lstinline!msgstr! are used.

At first there can be an optional comment describing the location (file name and line number) of the text to translate. Multiple occurences of the same string can be listed here, separated by space.

Then, the \lstinline!<context identifier>! behind the keyword \lstinline!msgctxt! is the full name of the Modelica class (e.g. \lstinline!Modelica.Blocks.Math.Sin!) where the text appears in.
Short class definitions do not appear here.
Texts in such classes belong to the enclosing full class definition.

After the `msgid` keyword the text string which shall be translated follows.
It should contain the original string from the Modelica text representation.
Since in Modelica control sequences also start with a backslash and another backslash is used to use sequences literally or to hide double quotes, no change is required here.
But Modelica allows strings to go over more than one line, gettext does not.
Therefore, Modelica strings must be split into consecutive strings at the line breaks, and the line breaks must be encoded with a \lstinline!"\n"! at the end of each string, e.g.
\begin{lstlisting}
"A
B"
\end{lstlisting}
is converted to
\begin{lstlisting}
"A\n"
"B"
\end{lstlisting}
These strings are concatenated when read.
\begin{nonnormative}
Please regard that if a \lstinline!msgid! string is given more than once in the same context, all occurrences are translated with the same (last) translation!
\end{nonnormative}

The keyword \lstinline!msgstr! is followed by the translation of \lstinline!msgid!.
With regard to control characters and line breaks, the same rules apply as for msgid.
In the template file this string is empty by definition.
If this is empty in a language specific file the contents of \lstinline!msgid! may be used instead.

The texts in following Modelica constructs should be translated:
\begin{itemize}
\item description strings of component declarations and classes
\item strings in following annotations:
\begin{itemize}
\item Text.string, Text.textString
\item missingInnerMessage, obsolete, unassignedMessage
\item Dialog.[group|tab]
\item Dialog.[load|save]Selector.[caption|filter]
\item Documentation.[info|revisions]
\item Figure.title, Plot.title, Curve.legend
\end{itemize}
\end{itemize}

C-style and line comments are not translated.

\begin{nonnormative}
To support the translation of that strings a number of free and commercial tools exist in context of GNU gettext.
A Modelica tool should provide a function to create the initial template file from an existing Modelica library.
\end{nonnormative}

0 comments on commit ce3d00e

Please sign in to comment.