Re: Where to place .pot file? + Hardcoded tab names change?

Karsten Hilbert <[email protected]> Sun, 27 Apr 2025 11:19:37 +0200
Newsgroups gmane.comp.gnu.medical.devel
Message-ID <[email protected]>
Am Sat, Apr 26, 2025 at 07:54:50PM -0300 schrieb Maria Scappini:

> I have written down a list of the few strings that I can't get translate=
d:
>=20
> /MAIN GUI MENU ITEMS/
>=20
>     In gnumed/client/wxpython/gmGuiMain.py :
>=20
>         - These are in the gmGuiMain.py file but not in the .po file:
>=20
>             - =E2=80=9C&Person=E2=80=9D (the name of the menu itself)
>             - Person =E2=86=92 =E2=80=9C&Import...=E2=80=9D
>             - Person =E2=86=92 =E2=80=9CE&xport...=E2=80=9D

Added.

>         - These appear in the gmGuiMain.py and .po file the same way but
>           don=E2=80=99t get translated for some reason:
>=20
>             - Person =E2=86=92 Export=E2=80=A6 =E2=86=92 =E2=80=9C=E2=86=
=92 Clipboard as=E2=80=A6=E2=80=9D =3D "\u2192 &Clipboard as\u2026"
>             - Person =E2=86=92 Export=E2=80=A6 =E2=86=92 =E2=80=9C=E2=86=
=92 File as=E2=80=A6=E2=80=9D =3D "\u2192 &File as\u2026"
>             - EMR =E2=86=92 Put into export area as ... =E2=86=92 =E2=80=
=9CJournal (mod time)=E2=80=9D
>             - Correspondence =E2=86=92 =E2=80=9C&Write letter=E2=80=9D
>             - Correspondence =E2=86=92 =E2=80=9CList Placeholders=E2=80=
=9D
>
>         - These appear in the gmGuiMain.py file and commented in the .po=
 file,
>           but even if I enable them (de-comment?) they don=E2=80=99t get=
 translated:
>=20
>             - EMR =E2=86=92 Manage =E2=80=A6 =E2=86=92 =E2=80=9C&Vaccina=
tions: by shot=E2=80=9D
>             - EMR =E2=86=92 Manage =E2=80=A6 =E2=86=92 =E2=80=9C&Vaccina=
tions: latest=E2=80=9D

Some of those were marked as "fuzzy", meaning there existed
an earlier translation of a similar string, which is being
suggested but put up for review (and not used for
translation at runtime until reviewed).

In case none of these reasons apply it may be useful to look
at the log :-)  because the runtime translation function in

	.../client/pycommon/gmI18N.py

applies some safeguards:


	def _translate_safely(term):
		"""This wraps _().

		It protects against translation errors such as a different number of "%s=
".
		"""
		translation =3D _translate_via_gettext(term)

		# different number of %s substitutes ?
		if translation.count('%s') !=3D term.count('%s'):
			_log.error('count("%s") mismatch, returning untranslated string')
			_log.error('original   : %s', term)
			_log.error('translation: %s', translation)
			return term

		substitution_keys_in_original =3D set(_substitutes_regex.findall(term))
		substitution_keys_in_translation =3D set(_substitutes_regex.findall(tran=
slation))

		if not substitution_keys_in_translation.issubset(substitution_keys_in_or=
iginal):
			_log.error('"%(...)s" keys in translation not a subset of keys in origi=
nal, returning untranslated string')
			_log.error('original   : %s', term)
			_log.error('translation: %s', translation)
			return term

		return translation

	(because without these safeguard GNUmed might crash just
	because someone installed an "evil" translation :-o

So, in case the number of '%s' (the marker for things to be
put into the text before display) is different between
original and translation it won't use the translated string.

Likewise, if not all of the named substitution keys
(%(key_name)s) of the translated string appear in the
original string it won't use the translation...

Both cases are logged for debugging :-)

Best,
Karsten
=2D-=20
GPG  40BE 5B0E C98E 1713 AFA6  5BC0 3BEA AC80 7D4F C89B