Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
.. contents::
i18ndude performs various tasks related to ZPT's, Python Scripts and i18n.
.. image:: https://github.com/collective/i18ndude/workflows/Tests/badge.svg :alt: GitHub Actions badge :target: https://github.com/collective/i18ndude/actions
i18ndude works with Python 3.8-3.11, and PyPy3. Older versions are not supported anymore, use the i18ndude 5.x series if you need that.
You can install i18ndude
with Buildout or pip
.
With pip
you may want to look at our requirements.txt <https://github.com/collective/i18ndude/blob/master/requirements.txt>
_.
UnicodeEncodeError
When running some i18ndude
commands, you might get a UnicodeEncodeError
.
This can especially happen when i18ndude
prints the result and you redirect the output or pipe it.
This is tricky, maybe impossible, to solve in i18ndude
itself.
See this related question on stackoverflow <https://stackoverflow.com/questions/492483/setting-the-correct-encoding-when-piping-stdout-in-python>
_.
This question points to a solution that you yourself can do when you encounter this.
In the (Unix-like) shell, do this::
export PYTHONIOENCODING=utf-8
This fixes UnicodeEncodeErrors when piping or redirecting output that contains non-ascii. I (Maurits) have this line in my bash profile now.
Note: if you get a UnicodeDecodeError
, so 'decode' instead of 'encode', then it may be something that needs fixing in i18ndude
.
Please report <https://github.com/collective/i18ndude/issues>
_ it then.
Since version 6 we have a pre-commit
hook available::
- repo: https://github.com/collective/i18ndude
rev: "master"
hooks:
- id: i18ndude
For now it only finds the strings not marked for translation.
These are the various command line options.
.. ### AUTOGENERATED FROM HERE ###
::
usage: i18ndude [-h] {find-untranslated,rebuild-pot,merge,sync,filter,admix,list,trmerge} ...
i18ndude performs various tasks related to ZPT's, Python Scripts and i18n.
Its main task is to extract translation strings (msgids) into a .pot file (with the 'rebuild-pot' command), and sync the .pot file with .po files (with the 'sync' command).
Call i18ndude with one of the listed subcommands followed by --help to get help for that subcommand.
options: -h, --help show this help message and exit
subcommands: {find-untranslated,rebuild-pot,merge,sync,filter,admix,list,trmerge}
::
usage: i18ndude find-untranslated [-h] [-s] [-n] [files ...]
Provide a list of ZPT filenames and I will output a report of places
where I suspect untranslated messages, i.e. tags for which
"i18n:translate" or "i18n:attributes" are missing.
If you provide the -s option, the report will only contain a summary
of errors and warnings for each file (or no output if there are no
errors or warnings). If you provide the -n option, the report will
contain only the errors for each file.
You can mark tags to be ignored for this translation check by
setting the "i18n:ignore" attribute on the tag. Same for
attributes with "i18n:ignore-attributes". Note that i18ndude may
be happy with this, but your template engine may fail when trying
to render a template containing those ignore hints. You need
Chameleon 2.23 or higher, or the to be released zope.tal 4.1.2.
positional arguments: files list of ZPT filenames
options: -h, --help show this help message and exit -s, --silent The report will only contain a summary of errors and warnings for each file (or no output if there are no errors or warnings). -n, --nosummary The report will contain only the errors for each file.
::
usage: i18ndude rebuild-pot [-h] [--wrap | --no-wrap] [--width NUMBER] -p filename [-c domain] [-m filename] [--merge2 filename] [--exclude " ..."] [--no-line-numbers] [--line-numbers] [path ...]
Given a pot-file via the --pot option you can specify one or more
directories which including all sub-folders will be searched for
PageTemplates (*.*pt) and Python scripts (*.*py).
Make sure you have a backup copy of the original pot-file in case
you need to fill back in ids by hand.
If you specify a domain in --create I will create the pot file and
look for messages for that domain. Otherwise I will take the
domain from the Domain header in the given pot file and keep the
headers from the file as base for a new pot file.
Note that in Python files we simply look for text within an underscore
method: _("..."). We do not know which domain this is.
If this finds text from a domain that you do not want to find,
you should give the underscore method for the unwanted domain
a different name, for example:
from zope.i18nmessageid import MessageFactory
PMF = MessageFactory("plone")
PMF("...")
If you give me an additional pot-file with the --merge <filename>
option, I try to merge these msgids into the target-pot file
afterwards. If a msgid already exists in the ones I found in the
ZPTs, I'll warn you and ignore that msgid. I take the mime-header
from this additional pot-file. If you provide a second pot-file via
--merge2 <filename> I'll merge this into the first merge's result
You can also provide a list of filenames (or regular expressions for
filenames) which should not be included by using the --exclude argument,
which takes a whitespace delimited list of files (or regular expressions
for files).
By default we add a comment showing references to file paths and line numbers
that contain the message, like this:
#: ./browser.py:32
You can suppress the line numbers by using the --no-line-numbers option.
The default might change in the future. If you love line numbers, you can
add --line-numbers to be sure you keep them when you get a newer version
of i18ndude. If you specify both options, the last one wins.
positional arguments: path
options: -h, --help show this help message and exit --wrap Wrap long lines. --no-wrap Do not wrap long lines. This is the default. --width NUMBER Set output page width. Default is 79. -p filename, --pot filename -c domain, --create domain -m filename, --merge filename --merge2 filename --exclude " ..." --no-line-numbers --line-numbers
::
usage: i18ndude merge [-h] [--wrap | --no-wrap] [--width NUMBER] -p filename -m filename [--merge2 filename]
Given a pot-file via the --pot option and a second
pot-file with the --merge <filename> option, I try to merge
these msgids into the target-pot file. If a msgid already
exists, I'll warn you and ignore that msgid.
If you provide a --merge2 <filename> I'll first merge this one
in addition to the first one.
options: -h, --help show this help message and exit --wrap Wrap long lines. --no-wrap Do not wrap long lines. This is the default. --width NUMBER Set output page width. Default is 79. -p filename, --pot filename -m filename, --merge filename --merge2 filename
::
usage: i18ndude sync [-h] [--wrap | --no-wrap] [--width NUMBER] -p potfilename pofilename [pofilename ...]
Given a pot-file with the --pot option and a list of po-files I'll
remove from the po files those message translations of which the
msgids are not in the pot-file and add messages that the pot-file has
but the po-file doesn't.
positional arguments: pofilename
options: -h, --help show this help message and exit --wrap Wrap long lines. --no-wrap Do not wrap long lines. This is the default. --width NUMBER Set output page width. Default is 79. -p potfilename, --pot potfilename
::
usage: i18ndude filter [-h] [--wrap | --no-wrap] [--width NUMBER] file1 file2
Given two pot-files I will write a copy of file1 to stdout with all
messages removed that are also in file2, i.e. where msgids match.
positional arguments: file1 file2
options: -h, --help show this help message and exit --wrap Wrap long lines. --no-wrap Do not wrap long lines. This is the default. --width NUMBER Set output page width. Default is 79.
::
usage: i18ndude admix [-h] [--wrap | --no-wrap] [--width NUMBER] file1 file2
Given two po-files I will look for translated entries in file2 that
are untranslated in file1. I add these translations (msgstrs) to
file1. Note that this will not affect the number of entries in file1.
The result will be on stdout.
positional arguments: file1 file2
options: -h, --help show this help message and exit --wrap Wrap long lines. --no-wrap Do not wrap long lines. This is the default. --width NUMBER Set output page width. Default is 79.
::
usage: i18ndude list [-h] -p product [product ...] [-t] [--tiered]
This will create a simple listing that displays how much of the
combined products pot's is translated for each language. Run this
from the directory containing the pot-files. The product name is
normally a domain name.
By default we show the languages of existing po files,
ordered by percentage.
With the --tiered option, we split the languages in three tiers or groups,
the first two with languages that Plone was traditionally translated in,
in a hardcoded order, followed by other languages.
This was the default output for years.
options: -h, --help show this help message and exit -p product [product ...], --products product [product ...] -t, --table Output as html table --tiered Show in traditional three-tiered order
::
usage: i18ndude trmerge [-h] [--wrap | --no-wrap] [--width NUMBER] [-i] [--no-override] file1 file2
Given two po-files I will update all translations from file2 into
file1. Missing translations are added.
If a translation was fuzzy in file1, and there is a nonempty translation
in file2, the fuzzy marker is removed.
Fuzzy translations in file2 are ignored.
The result will be on stdout. If you want to update the first
file in place, use a temporary file, something like this:
i18ndude trmerge file1.po file2.po > tmp_merge && mv tmp_merge file1.po
positional arguments: file1 file2
options: -h, --help show this help message and exit --wrap Wrap long lines. --no-wrap Do not wrap long lines. This is the default. --width NUMBER Set output page width. Default is 79. -i, --ignore-extra Ignore extra messages: do not add msgids that are not in the original po-file. Only update translations for existing msgids. --no-override Do not override translations, only add missing translations.
.. You should NOT be adding new change log entries to this file. You should create a file in the news directory instead. For helpful instructions, please see: https://github.com/plone/plone.releaser/blob/master/ADD-A-NEWS-ITEM.rst
.. towncrier release notes start
Bug fixes:
New features:
New features:
Bug fixes:
Bug fixes:
Breaking changes:
New features:
Bug fixes:
prepare_cli_documentation
command.
[gforcada] (#101)New features:
--no-line-numbers
option to rebuild-pot
.
Use this to prevent including line numbers in pot files.
The default is to still include them, so no behavior change.
The default could change in the future.
If you want to be sure to keep your line numbers in the future, use the new --line-numbers
option.
[maurits] (#77)Bug fixes:
Bug fixes:
tal:define="(text,url) python:view.linkinfo"
.
This avoids TALError: invalid define syntax
when extracting messages from templates that use this.
[maurits] (#36)New features:
i18ndude rebuild-pot --exclude="name1 name2"
now also accepts directory names for exclusion.
Excluding a directory name will exclude all files in and below the given directory,
but only if the directory name exactly matches a exclusion name (no globs, no substring match).
This change now also results in the hardcoded exclusions for 'tests' and 'docs' to actually work. (#86)Bug fixes:
Bug fixes:
Bug fixes:
Bug fixes:
rebuild-pot
help about unwanted domains in Python files.
[maurits] (#49)Bug fixes:
i18n:name
attributes when running find-untranslated
code analysis. [gyst] (#71)New features:
Bug fixes:
New features:
Bug fixes:
Fixed plone.i18n
import.
It was a conditional import to change the names of languages in the list, so nothing serious.
But it always failed.
[maurits]
In the readme, suggest export PYTHONIOENCODING=utf-8
to fix UnicodeEncodeErrors
.
(Note: not UnicodeDecodeErrors
.)
Fixes issue 55 <https://github.com/collective/i18ndude/issues/55>
_.
[maurits]
New features:
list
command, show only languages with existing po files,
ordered by percentage. A new --tiered
option uses the traditional
behavior with languages in a specific order in three tiers.
[maurits]Bug fixes:
Sort files that we extract messages from. On Linux they were already sorted, but not on Mac, leading to a test failure. [maurits]
Fixed another possible UnicodeDecodeError in find-untranslated. [maurits]
find-untranslated
no longer complains about attributes with chameleon syntax.
An html tag with title="${context/Description}"
is no longer
marked as having an untranslated title tag.
Fixes issue 53 <https://github.com/collective/i18ndude/issues/53>
_.
[maurits]
issue 52 <https://github.com/collective/i18ndude/issues/52>
_.
[maurits]Breaking changes:
New features:
Bug fixes:
Removed ordereddict
and ```argparse`` dependencies completely.
[maurits]
Fixed many unicode/string/bytes handling problems. There's probably still some unfixed that need finding, given that test coverage is only 63%. [gyst]
Todo:
New:
Support Chameleon repeat syntax in templates.
Fixes issue #36 <https://github.com/collective/i18ndude/issues/36>
_.
[maurits]
Moved plone.i18n
dependency to a plone
extra.
This is only used for getting language names in the list
command.
We now fall back to using the language name that is in the po
files.
Fixes issue #44 <https://github.com/collective/i18ndude/issues/44>
_.
[maurits]
New:
In find-untranslated
, do not report items that get replaced by Chameleon syntax.
So <span>${view/test}</span>
will no longer get flagged as missing a translation.
(Note that you still can add i18n:translate
if it makes sense,
like Plone does for translating the dynamically calculated review state.)
[Netroxen, maurits]
Find untranslated attributes now also checks for 'placeholder' attributes on input tags.
New:
*.py
to exclude all python files. This doesn't break existing
behavior. Do remember to use quotes around the expression.
[laulaz, maurits]Fixes:
New:
Extract strings from zcml. Issue #28 [maurits]
No longer print two blank lines at the end of .po and .pot files. [maurits]
In the find-untranslated command, first try to parse a template as
xml, which is good for non-html files. If that fails, try to parse
it as html with a little help from the lxml HTMLPaser, which handles
html5 code much better. If that fails, use our trusty home grown
common.prepare_xml
function, which treats everything as old
html. Note that we still use xml.sax
as the core parser here.
Issue #15
[maurits]
Ignore hidden files in the find-untranslated command. Issue #29 [maurits]
Use lxml instead of xml.etree or elementtree for parsing GenericSetup xml files. [maurits]
New:
First try the original zope.tal parser. Only when this fails we try our own parser/generator. [maurits]
Support Chameleon unnamed attributes without crashing. For example:
tal:attributes="python:{'data-something': 'chameleon-only'}"
[maurits]
Support chameleon attributes tal:switch and tal:case. Fixes issue #24. [ale-rt]
Fixes:
Check tal:condition
correctly when it is in a tal:something
tag.
[maurits]
In find-untranslated
only ignore tal:condition="nothing"
,
not other conditions.
Fixes issue #16.
[maurits]
Improved the prepare_xml
function. This tries to work around
templates that miss the usual boiler plate, like
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
. But there
were some silly errors in it.
This refs issue #16.
[maurits]
nosummary
option from find-untranslated
.
It was reporting wrong information.
[gforcada]Fix encoding errors with wrapAndQuoteString. [thet]
Pep8. [thet]
Releasing as Python wheel too. [maurits]
Fixed wrapping when string contains newline. Issue #13 [maurits]
Drop Python 2.6 support. It may still work, but the tests only run on Python 2.7. Note that it is fine to use one central i18ndude command for all your projects, no matter what Python version they are using. [janjaapdriessen, maurits]
For the find-untranslated feature, add the possibility to mark a tag to be ignored by setting the "i18n:ignore" attribute on the tag. Also works for attributes with the "i18n:ignore-attributes" attribute. [janjaapdriessen]
.po
file is missing an empty msgid and msgstr near the
top. This is fixed automatically, although it will override some
headers.
[maurits]trmerge
: do not override when the mixin translation is fuzzy.
[maurits]
trmerge
: add --no-override
argument. This means: do not
override translations, only add missing translations.
[maurits]
trmerge
: add --ignore-extra
option. This ignores extra msgids
in the second po-file.
[maurits]
Update script.py in some cases "arguments.exclude" is None. [giacomos]
Fixed optional parameter exclude. [shylux]
Add command line documentation to long description of package. [maurits]
Add options --wrap
, --no-wrap
and --width=NUMBER
to all
commands that write files. Use these to determine whether long
lines are wrapped and at which width. Default width is 79. By
default we do NOT wrap, because we have never wrapped before. This
may change in the future, so if you really want to be sure to not
wrap when using a future i18ndude version, you can add --no-wrap
now.
https://github.com/collective/i18ndude/issues/3
[maurits]
Fix the list
command to also work in a locales
structure.
[maurits]
Fix an error in the merge
command where the --merge
option
would be used as value for the --merge2
option as well, if that
option itself was unused. This led to unneeded warnings.
[maurits]
The --create domain
option of rebuild-pot
is now optional.
If not given, i18ndude reads the domain from the given .pot
file. It was always optional, but the documentation did not show it
and it did not work.
[maurits]
Update the command line options handling. You can now get the help
for individual commands by calling them with the --help
option.
[maurits]
Return exit code 1 when the called function gives an error. This
currently only has an effect when calling find-untranslated
.
https://github.com/collective/i18ndude/issues/1
[maurits]
Moved code to https://github.com/collective/i18ndude [maurits]
Backslash escape added to msgid when it includes double quotes. [taito]
Add trmerge command to merge po files. Custom tailored for transifex. [do3cc]
elementtree is only required for Python < 2.5. [vincentfretin]
Fixed tests (patch provided by John Trammell). [vincentfretin]
Support for explicit msgids in GSReader. [vincentfretin]
Better handling of msgid references. Keep all the references in PTReader and PYReader. In POWriter, normalize and sort the references, write only MAX_OCCUR (default is 3) references. You can set MAX_OCCUR=None if you want all references to be written to the generated POT file. Only the first reference is written in case of several references to the same file but with different line number. [vincentfretin]
Depend now on zope.tal 3.5.2 to print a warning when msgid already exists in catalog with a different default message. Simplified PTReader code. Check for msgid with different default in GSReader, PYReader and in the merged catalog (ptctl, pyctl, gsctl). [vincentfretin]
Fix behaviour when dealing with broken xml files to be parsed. [afd]
For older changes, see docs/ChangeLog
.
FAQs
i18ndude performs various tasks related to ZPT's, Python Scripts and i18n.
We found that i18ndude demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.