Giter Club home page Giter Club logo

sphinx-intl's Introduction

sphinx-intl's People

Contributors

12rambau avatar agjohnson avatar armandciejak avatar clalarco avatar cocoatomo avatar delazj avatar giacomos avatar guitorri avatar ideasman42 avatar igo95862 avatar jdknight avatar jenselme avatar jpmckinney avatar kloczek avatar knzm avatar rffontenelle avatar s0undt3ch avatar shimizukawa avatar soishino avatar thetriplev avatar tk0miya avatar xie-dongping avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sphinx-intl's Issues

Documentation

The document should be hosted on ReadTheDocs before 1.0 release.

locale_dir should default to 'locales'

The default value of locale_dirs is ['locales'] since Sphinx 1.5.
Therefore, for consistency and convenience, the name of default output directory of sphinx-intl should be a 'locales' directory.

Documentation corrections

I read your documentation, and noticed several errors or typos. I report the most obvious ones.
It would be great if a native speaker could read that all and correct. Thanks for your work.

Please install sphinx-intl with using pip (8.1.1 or later).

better:
Please install sphinx-intl using pip (8.1.1 or later). (or only with)
https://sphinx-intl.readthedocs.io/en/master/quickstart.html#installation

This section describes how to translate with Sphinx and sphinx-intl command.
https://sphinx-intl.readthedocs.io/en/master/quickstart.html#quickstart-for-sphinx-translation

This invokes the sphinx gettext builder that generates *.pot files under _build/gettext directory.
(same link below)

After this, you got (better get?) these directories that contain po files:

For more information, please refer to References.
https://ell.stackexchange.com/questions/58525/what-is-the-difference-between-refer-the-letter-and-refer-to-the-letter

When I run

$ sphinx-intl update -p _build/gettext -l ru
Usage: sphinx-intl update [OPTIONS]

Error: Invalid value for pot_dir: '_build/gettext' is not exist. 
Please specify pot directory with -p option,
or preparing your pot files in '_build/gettext'.

the error message must be does not exist (not is). or prepare.

Type sphinx-intl without arguments * - remove, options)* to show command help.
https://sphinx-intl.readthedocs.io/en/master/refs.html

Dashes (-) have to be replaced with underscores (_).

*(redundant) This * is the same as passing the option to sphinx-intl directly:

Add below settings to sphinx document’s conf.py if they do not exist:

however pot files should be generated in the locale/pot is convenient. You can be done by replacing
-- pot files generated in the locale/pot are convenient. (think of rewriting that)

Definition of be done with (not by)
: to bring to completion : to finish
https://www.merriam-webster.com/dictionary/be%20done%20with
If you are sure this is what you want to say, that's fine. For me it sounds a bit vague. Simple words may be better here. You can solve this by...

i18n: Translated msgid strings in content files not merged into HTML output

Since upgrading from Sphinx 1.8 to 2.1, the translated strings in the PO files in my /locale//LC_MESSAGES/ directory are no longer merged into the HTML output. However, the translated strings for my RTD theme are merged into the output. I've upgraded my copy of sphinx-intl to v2.0.0 in case that was the issue; it isn't.

I'm following the same process as before the Sphinx upgrade:

  1. Run make gettext to produce a set of POT files.
  2. Run sphinx-intl update -p build/locale -l de (to produce PO files for German translation).
  3. Translate the strings. For example:

#: ../../source/index.rst:8
msgid "English string"
msgstr "German string"

  1. Run the command to build my HTML output:

make -e SPHINXOPTS="-D language='de' -D locale_dirs='locale/,_themes/rtd_theme/locale/' -D html_theme='rtd_theme'" BUILDDIR="build/de" clean html

Sphinx creates the MO files from my PO files. The HTML output shows the translated strings for my theme but not for my content files.

When I downgrade my environment and use Python 2.7 tools to build translated output (into German), Sphinx successfully replaces the strings in my RST files with the corresponding strings in my PO files in the HTML output:
i18n-translated-strings-not-merged-into-output.zip

Python 2.7
Sphinx 1.8.4
Sphinx-intl 0.9.9

However, when I switch back to the Python 3 tools, Sphinx does replace the strings in my RTD theme sphinx.po file but does not replace the strings in my RST content files (index.po, .po):

Python 3.5
Sphinx 2.2.0
Sphinx-intl 2.0.0

I don't see any earlier reports of similar issues. Any idea what could be going on? The msgid strings in my PO files line up with the strings in my RST files, so that isn't the issue.

Mark

How to automatically access each language version documents by browser settings?

Thank you for your repository!

Maybe It's a very foolish question.

I successfully generated Korean version documents and English version.

And I thought It can be redirected to Korean version if my browser set up with Korean (vice versa), but It's not.

Is there any guide to setup or reference?

again, Thank you for your effort!

Add an option for configuring the maximum line width of the generated PO files

It is currently not possible to configure it, the Babel default is used (76). Having the possibility to configure it would help when working with graphical PO editors like poedit which usually wrap line at 80 characters.
When using such an editor with the PO files tracked in a version control system, the diff are useless: all lines change because of the line being wrapped differently by sphinx-intl and the editor.

sphinx-intl is using the relative path to cwd not conf.py

I'm using nox to build most of my automated process now and that include generating the translation .pot files for my documentation.

Before I was running:

cd docs 
sphinx-intl update -p build/gettext -l fr -l en

now I would like to run it from the root of my repository as:

sphinx-intl update -p docs/build/gettext -l fr -l en

When I do the last one, the conf.py file is not detected and all my pot files are saved in a default locales directory even though I use _locale in my conf.py.

Is it possible to specify the location of the conf.py file to the command ? If not, could we add this option ?

sphinx-intl errors if conf.py contains tag logic

I use tags to separate "internal" and "external" content in my documentation. So .. only:: internal and .. only:: external.

Then I build with sphinx-build -b html -t external _build/external-html/ or -t internal.

In conf.py, I have several statements like this:

if tags.has('external'):
    html_copy_source = False

This statement causes sphinx-intl to fail on build:

$ make clean gettext

rm -rf _build/*
sphinx-build -b gettext -t external  . _build/locale
Running Sphinx v1.4.9

...

Build finished. The message catalogs are in _build/locale.

$ sphinx-intl update -p _build/locale/ -l fr

Traceback (most recent call last):
  File "/usr/local/bin/sphinx-intl", line 11, in <module>
    sys.exit(main())
  File "/Library/Python/2.7/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/Library/Python/2.7/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/Library/Python/2.7/site-packages/click/core.py", line 1057, in invoke
    Command.invoke(self, ctx)
  File "/Library/Python/2.7/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Library/Python/2.7/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/Library/Python/2.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Library/Python/2.7/site-packages/sphinx_intl/commands.py", line 154, in main
    cfg = read_config(ctx.config)
  File "/Library/Python/2.7/site-packages/sphinx_intl/commands.py", line 38, in read_config
    execfile_(os.path.basename(path), namespace)
  File "/Library/Python/2.7/site-packages/sphinx_intl/pycompat.py", line 84, in execfile_
    exec_(code, _globals)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.py", line 508, in exec_
    exec("""exec _code_ in _globs_, _locs_""")
  File "<string>", line 1, in <module>
  File "conf.py", line 51, in <module>
    if tags.has('external'):
NameError: name 'tags' is not defined

I can scrub the if statements before running sphinx-intl, but obviously that's not ideal. Thanks for any help or guidance here!

make gettext

hi, when use make gettext in my docs, "startswith" error caused:

Exception occurred:
File "/Users/xx/anaconda/lib/python2.7/posixpath.py", line 54, in isabs
return s.startswith('/')
AttributeError: StringList instance has no attribute 'startswith'
The full traceback has been saved in /var/folders/hq/x053v2n52fbbkyd99d_46ywh0000gn/T/sphinx-err-wgSdEl.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at https://bitbucket.org/birkenfeld/sphinx/issues/. Thanks!
make: *** [gettext] Error 1

anyone knows how to do ? thanks

unnecessary <p class="first"> was inserted between <li>

I translated some text in .po file like this:

_002

then use sphinx-intl to generate html

sphinx-intl build 
make -e SPHINXOPTS="-D language='zh-CN'" html

finally, some unnecessary <p class="first"> has been inserted between <li>

_001

sphinx-intl is not reading SPHINXOPTS

Hi:

I use tags inside conf.py for some variables required by the filenames, in particular to set htmlhelp_basename.

To do this I use SPHINXOPTS=-tdoc1 or SPHINXOPTS=-tdoc2, and in conf.py:

if tags.has('doc1'):
    htmlhelp_basename = 'doc1'
elif tags.has('doc2'):
    htmlhelp_basename = 'doc2'

However, these options are not used when reading conf.py, hence the sphinx-intl fails.

Any help will be appreciated, thanks.

Feature request: update-txconfig-resources basing on the Sphinx sources

Currently update-txconfig-resources requires a tree structure of POT files as the command argument. That requires building the Sphinx documentation with gettext builder, which takes time.

It would be cool to make the process more lightweight and be able to update tx config without the need of making a full build of the documentation.

Figure numbering not localised

Hi guys,

I'm trying to localise a document from English into Japanese. In general it's looking good but the auto-numbered figures end up formatted "Fig. 3.3ロボット" and ideally I would prefer them to be "図3.3: ロボット". The same is true for the output of a naive :numref: call. Is there any functionality that would allow me to change this behaviour? For example, a localisation config I've missed, or a way of setting a language-specific style file? Would it work to use a glossary?

Any help would be greatly appreciated!

All the best,
Harry Jordan

Question: does a page have the resource-key at build time

Thanks for all this work!!

We (QGIS-project) use sphinx/sphinx-intl/transifex to build/translate our documentation
Eg: https://docs.qgis.org/3.10/ja/docs/

In an earlier version of the docs we created the 'resource-keys' for transifex ourselves, and in that way were able to generate a 'translate this page here' link into every page footer, linking to the exact resource in transifex.

Now we use sphinx-intl update-txconfig-resources

and .tx/config contains keys like:

qgis-documentation.docs--user_manual--introduction--qgis_gui

which can be found on transifex here:

https://www.transifex.com/qgis/qgis-documentation/translate/#ja/docs--user_manual--introduction--qgis_gui

So I was wondering if the machinery to 'create' these keys were also available (or put in some context) during the build of the html pages?

In that way it would be easy to construct direct links to transifex.

I am aware that the build of html and tx-config are two separate processes... so maybe it is harder then I hope :-)

TIA

cannot find tag 1.0.0

Hi,

I cannot find commit tagged as 1.0.0 in git log

$ git show 1.0.0
warning: refname '1.0.0' is ambiguous.
commit f412899a85dd418be67a79dca1ceaa50cec97b49 (tag: 1.0.0)
Author: shimizukawa <[email protected]>
Date:   Sun May 12 17:52:50 2019 +0900

    fix broken url

diff --git a/README.rst b/README.rst
index 0696fad..ff38bf3 100644
--- a/README.rst
+++ b/README.rst
@@ -45,4 +45,4 @@ Licensed under the BSD license.
 CHANGES
 =======
 
-See: https://github.com/sphinx-doc/sphinx-intl/blob/master/CHANGES
+See: https://sphinx-intl.readthedocs.io/en/master/changes.html
\ No newline at end of file

However, there's no commit f412899a85dd418be67a79dca1ceaa50cec97b49 in git log.

Sidebar titles don't localize

Running sphinx-intl on Windows, I get sidebar titles excluded from po files. Whereas under OS X, these titles are successfully added for localization.
Is there any way to include sidebar titles under Windows?

No way to to create MO files in a separate directory.

Creating the MO files next to the PO files is problematic for source control, which may try to remove directories on updating (which will fail if files out of source control are present), less experienced translators may accidentally commit the MO files too (this just happened in fact).

Ideally: sphinx-intl build could take an --output-dir argument.

If this is acceptable, I can write up a patch to add support for this.

Build fails with incorrectly formatted time/date

We have translations running on a server and if there is some inconsistency, error causes the build to fail.

I ran into a case where a PO file prevents the entire build from running:

PO file:

# SOME DESCRIPTIVE TITLE.
# Copyright (C) : This page is licensed under a CC-BY-SA 4.0 Int. License
# This file is distributed under the same license as the Blender 2.78 Manual
# package.
# urko <[email protected]>, 2017.
#
msgid ""
msgstr ""
"Project-Id-Version: Blender 2.78 Manual 2.78\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date: 2017-07-20 13:32+0300\n"
"Last-Translator: urko <[email protected]>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.4.0\n"
"X-Generator: Poedit 2.0.2\n"
"Language: uk\n"

#: ../../manual/index.rst:5
msgid "Blender Reference Manual"
msgstr "Blender Reference Manual"
Build: locale/uk/LC_MESSAGES/index.mo
Traceback (most recent call last):
  File "/usr/local/bin/sphinx-intl", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/sphinx_intl/commands.py", line 247, in build
    basic.build(locale_dir, output_dir, languages)
  File "/usr/local/lib/python3.6/site-packages/sphinx_intl/basic.py", line 101, in build
    cat = c.load_po(po_file)
  File "/usr/local/lib/python3.6/site-packages/sphinx_intl/catalog.py", line 17, in load_po
    cat = pofile.read_po(f)
  File "/usr/local/lib/python3.6/site-packages/babel/messages/pofile.py", line 331, in read_po
    parser.parse(fileobj)
  File "/usr/local/lib/python3.6/site-packages/babel/messages/pofile.py", line 265, in parse
    self._process_comment(line)
  File "/usr/local/lib/python3.6/site-packages/babel/messages/pofile.py", line 224, in _process_comment
    self._finish_current_message()
  File "/usr/local/lib/python3.6/site-packages/babel/messages/pofile.py", line 164, in _finish_current_message
    self._add_message()
  File "/usr/local/lib/python3.6/site-packages/babel/messages/pofile.py", line 158, in _add_message
    self.catalog[msgid] = message
  File "/usr/local/lib/python3.6/site-packages/babel/messages/catalog.py", line 603, in __setitem__
    self.mime_headers = _parse_header(message.string).items()
  File "/usr/local/lib/python3.6/site-packages/babel/messages/catalog.py", line 418, in _set_mime_headers
    self.creation_date = _parse_datetime_header(value)
  File "/usr/local/lib/python3.6/site-packages/babel/messages/catalog.py", line 46, in _parse_datetime_header
    tt = time.strptime(match.group('datetime'), '%Y-%m-%d %H:%M')
  File "/usr/local/lib/python3.6/_strptime.py", line 559, in _strptime_time
    tt = _strptime(data_string, format)[0]
  File "/usr/local/lib/python3.6/_strptime.py", line 362, in _strptime
    (data_string, format))
ValueError: time data 'YEAR-MO-DA HO:MI+ZONE' does not match format '%Y-%m-%d %H:%M'

FileNotFoundError occured

Following error occred in sphinx-intl update-txconfig-resources -p pot -d .

FileNotFoundError: [Errno 2] No such file or directory: 'pot/UsersGuide.pot'
FROM ubuntu:latest

RUN apt-get update
RUN apt-get -y install git
RUN git clone https://gitlab.com/OpenCAE/paraview-docs-translation.git
WORKDIR /paraview-docs-translation
RUN git submodule init
RUN git submodule update
RUN apt-get -y install python3-pip
RUN pip3 install -r ./requirements.txt
RUN pip3 install -r ./paraview-docs/doc/requirements.txt

ENV SPHINXINTL_TRANSIFEX_PROJECT_NAME=paraview-docs
ENV SPHINXINTL_TRANSIFEX_USERNAME=api

RUN sh ./locale/update.sh

How response to the source document updates?

I noticed that execete

make gettext
sphinx-intl  update -l <lang>

the regenerated .po file retained the previous translation content,
but I only saw the file update prompt on the terminal during executed command,
so how does the translator know which files was updated and need to translate?
Something like adding an update tag in the appropriate place in the .po file?
I have also learned that transifex provide XLIFF file containd untranslated content, but this feature is available in the paid version.

Thank you for any guidance.

Different TX Config ordering for Windows and Linux

Seems like the ordering is completely different for Windows and Linux. On Windows it seems to sort alphabetical while on my linux machine it's quite haphazard.

This completely breaks cross-platform usability.

Release version 2.1.0

Due to @rffontenelle's work we can now release v2.1.0.

The changelog (CHANGES.rst) should be updated to reflect the move to the new CLI tool and dropping 3.5.

A

AttributeError: can't set attribute

Hi,

I'm trying to figure out why i can't update my po files. I'm not a python guy. What do you make of this backtrace?

I'm running python 2.7.10

Thanks,

Mike

$ sphinx-intl update -d /srv/ddx-docs/cml/_locale -p /srv/ddx-docs/cml/_locale/all -l frNot Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/contextual-help-index.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/index.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/contextual-help-330-index.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/index-cmil330.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/index-cmil400.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/revenue-outlook-report/description.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/revenue-outlook-report/reading.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/revenue-outlook-report/index.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/revenue-outlook-report/parameters.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/revenue-outlook-report/open-page.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/revenue-report/description.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/revenue-report/reading.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/revenue-report/index.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/revenue-report/parameters.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/revenue-report/open-page.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/practices/description.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/practices/add-labnext.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/practices/list.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/practices/index.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/practices/starting-balances-labnext.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/practices/assigning-taxes-labnext.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/practices/field-refs.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/practices/open-preferences-tab.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/practices/open-list-page.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/lab/description.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/lab/index.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/lab/default/description.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/lab/default/index.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/lab/default/files/index.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/lab/default/file/index.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/lab/default/partners/index.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/lab/default/open-tasks/index-labnext.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/lab/default/dashboard/index.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/lab/finances/description.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/lab/finances/index-labnext.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/lab/finances/transaction/index-labnext.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/lab/finances/credit/index-labnext.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/lab/finances/statements/index-labnext.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/lab/finances/postings/index-labnext.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/lab/finances/estimate/index-labnext.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/lab/finances/payment/index-labnext.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/lab/finances/statement/index-labnext.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/lab/finances/invoice/index-labnext.po
Not Changed: /srv/ddx-docs/cml/_locale/fr/LC_MESSAGES/lab/gnav/description.po
Traceback (most recent call last):
  File "/usr/local/bin/sphinx-intl", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/sphinx_intl/commands.py", line 227, in update
    basic.update(locale_dir, pot_dir, languages)
  File "/usr/local/lib/python2.7/dist-packages/sphinx_intl/basic.py", line 55, in update
    c.update_with_fuzzy(cat, cat_pot)
  File "/usr/local/lib/python2.7/dist-packages/sphinx_intl/catalog.py", line 92, in update_with_fuzzy
    new.fuzzy = True
AttributeError: can't set attribute

Customize po header

# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2019, TubeMQ Team
# This file is distributed under the same license as the TubeMQ package.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2019.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: TubeMQ \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-10-29 20:40+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.7.0\n"

I'd like to customize LICENSE header as well as no "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" and "Language-Team: LANGUAGE <[email protected]>\n" and # FIRST AUTHOR <EMAIL@ADDRESS>, 2019.

Is there an option to do that instead of manually remove then from generated?

The "sphinx-intl update" command should not change existing msgstr

Hi! I followed the instructions in the Sphinx docs to generate the .pot and .po files in this repo.

Now after the .rst source has changed, I tried to update the .po files with the following commands:

$ make gettext
$ sphinx-intl update -p _build/gettext

But I found some unexpected changes (flaskcwg/flask-docs-zh#35):

  • Some Chinese words added as msgid for the API reference docs (ref).
  • The msgid of alt of images was replaced with the translated msgstr (ref).
  • Some multiline msgstr was reordered based on the position of the English word (ref).

The last one brings quite a bit messy (see the ref for the example). Is there any method to disable the update command to change the existing msgstr? I didn't found any related issues or documentation. And the -w option only changes the max line length of msgid.

Sphinx: 4.0.2
sphinx-intl: 2.0.1
Python: 3.8 (Windows 10)

Thanks!

Transifex's tx client seems to have changed behavior for resource naming

Previously, I could use the .tx/config file created by sphinx-intl update-txconfig-resources to upload resources, whose name would match the resource ID, e.g. "tariffs--1_1--codelists", which comes from normalizing the resource's local file path.

Now, in Transifex, for new resources, the resource shows up with a name that corresponds to the basename of the source_file, e.g. codelists.pot.

The earlier behavior can be restored by setting resource_name in the config file (i.e. adding --resource-name to the tx add command in transifex.py).

If this project doesn't want to hardcode resource_name to the resource ID, I would appreciate an opt-in flag for this behavior.

use pyproject.toml instead of setup.py

pip is now outputting deprecation warning when installing projects setup.py-based in favor of pyproject.toml :

DEPRECATION: sphinx-intl is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at pypa/pip#8559

Not working on Windows

I followed exact steps in read me and in Sphinx documentation, but the output is always in English. All in all sphinx-intl documentation is not very clear, leaving a lot of room for trial and error.

Documentation says make gettext will generate pot files into _build/locale directory however running make gettext always generates files in _build\gettext folder.

allow to specify translation context

For Russian, some users said they wanted to have separate translations for the same source strings. This is accomplished by translation contexts, eg:

#: src/gui/widgets/preferences.c:858
msgctxt "guilabel"
msgid "Plugins"
msgstr "プラグイン"

please make it possible to specify a translation context. if not for individual strings, at least make it possible to specify a context for the whole project that sphinx-intl is processing (since my translations are shared with other projects). maybe add a command line option --context?

Internationalization with multi project sphinx setup not using .po files

I have a some projects which all uses the same core project. For these projects I've setup sphinx to generate the same core documentation in all projects and mix it with each project specific documentation using a simple symbolic link.

$ cd /path/to/subproject/a/docs
$ ln -s /path/to/coreproject/docs core
$ make html

Now I want to have internationalization using sphinx-intl but I can't get the documentation from the core project to to use the .po files.

I've tried setting locale_dirs = ['locale/', 'core/locale/'] and then running the following commands from my subproject:

$ make gettext
$ sphinx-intl update -p _build/gettext -l sv
$ make -e SPHINXOPTS="-D language='sv'" html

I've also created a question on stackoverflow here

sphinx-intl update adds python-format flag to messages containing %

Given a POT file with a message that contains a %, sphinx-intl update will produce a PO file where that message has an added #, python-format flag. That flag indicates that the message is a python format string, but all sphinx-intl messages should come from RST.

Example POT file:

# pot_dir/test.pot

msgid ""
msgstr ""

msgid "the % of change in sediment"
msgstr ""

Produces this PO file:

msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2021-12-06 15:01-0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.9.1\n"

#, python-format
msgid "the % of change in sediment"
msgstr ""

Include example(s)

A working example included in the repository would be very beneficial for users trying to translate their documentation projects.

Release 2.2.0?

It has been a year since 2.1.0, and the bug fix from #90 would be really great.

Unable to generate .po files for specific .rst file

I am trying the below methods to generate the .po file for a specific .rst file, instead of the entire folder. But there seem to be no such options with what I am trying.

Try 1: Dint work
sphinx-intl update --input-file path/to/file.rst -p build/gettext -l ja

Try 1: Dint work:
sphinx-intl update -p build/gettext -l ja --source-dir path/to/source/dir path/to/file.rst

Default command which works:
sphinx-intl update -p build/gettext -l ja

f-string used in transifex.py, but python 3.5 doesn't support f-string

Checking the Actions log, I saw the CI failing in Python 3.5 with rasing SyntaxError exception because there of {TRANSIFEX_CLI_MINIMUM_VERSION} in the code block in the line 85 of sphinx_intl/transifex.py:

        msg = textwrap.dedent(f"""\
        An unsupported version of the Transifex CLI was found.
        Version {TRANSIFEX_CLI_MINIMUM_VERSION} or greater is required.
        Please run the below command if you want to use this action:
            $ tx update
        """)

f-strings are available since Python 3.6, see PEP 498.

See full error log
  py35 installdeps: -e.[transifex,test]
  py35 inst: /home/runner/work/sphinx-intl/sphinx-intl/.tox/.tmp/package/1/sphinx-intl-2.1.0.dev20221021.zip
  py35 installed: DEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove support for this functionality.,alabaster==0.7.12,attrs==22.1.0,Babel==2.9.1,certifi==2021.10.8,chardet==4.0.0,click==7.1.2,docutils==0.16,idna==2.10,imagesize==1.4.1,importlib-metadata==2.1.3,iniconfig==1.1.1,Jinja2==2.11.3,MarkupSafe==1.1.1,mock==3.0.5,packaging==20.9,pathlib2==2.3.7.post1,pluggy==0.13.1,py==1.11.0,Pygments==2.11.2,pyparsing==2.4.7,pytest==6.1.2,pytz==2022.5,requests==2.25.1,six==1.16.0,snowballstemmer==2.2.0,Sphinx==3.5.4,sphinx-intl @ file:///home/runner/work/sphinx-intl/sphinx-intl/.tox/.tmp/package/1/sphinx-intl-2.1.0.dev20221021.zip,sphinxcontrib-applehelp==1.0.2,sphinxcontrib-devhelp==1.0.2,sphinxcontrib-htmlhelp==1.0.3,sphinxcontrib-jsmath==1.0.1,sphinxcontrib-qthelp==1.0.3,sphinxcontrib-serializinghtml==1.1.5,toml==0.10.2,urllib3==1.26.9,zipp==1.2.0
  py35 run-test-pre: PYTHONHASHSEED='1964382961'
  py35 run-test: commands[0] | py.test -v --durations=25
  ============================= test session starts ==============================
  platform linux -- Python 3.5.10, pytest-6.1.2, py-1.11.0, pluggy-0.13.1 -- /home/runner/work/sphinx-intl/sphinx-intl/.tox/py35/bin/python
  cachedir: .tox/py35/.pytest_cache
  rootdir: /home/runner/work/sphinx-intl/sphinx-intl
  collecting ... collected 8 items / 3 errors / 5 selected

==================================== ERRORS ====================================
____________________ ERROR collecting tests/test_cmd_pot.py ____________________
.tox/py35/lib/python3.5/site-packages/_pytest/python.py:571: in _importtestmodule
mod = import_path(self.fspath, mode=importmode)
.tox/py35/lib/python3.5/site-packages/_pytest/pathlib.py:517: in import_path
importlib.import_module(module_name)
/opt/hostedtoolcache/Python/3.5.10/x64/lib/python3.5/importlib/init.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
:985: in _gcd_import
???
:968: in _find_and_load
???
:957: in _find_and_load_unlocked
???
:673: in _load_unlocked
???
.tox/py35/lib/python3.5/site-packages/_pytest/assertion/rewrite.py:171: in exec_module
exec(co, module.dict)
tests/test_cmd_pot.py:13: in
from sphinx_intl import commands
.tox/py35/lib/python3.5/site-packages/sphinx_intl/commands.py:18: in
from . import transifex
E File "/home/runner/work/sphinx-intl/sphinx-intl/.tox/py35/lib/python3.5/site-packages/sphinx_intl/transifex.py", line 93
E msg = textwrap.dedent(f"""
E An unsupported version of the Transifex CLI was found.
E Version {TRANSIFEX_CLI_MINIMUM_VERSION} or greater is required.
E Please run the below command if you want to use this action:
E ^
E SyntaxError: invalid syntax
___________________ ERROR collecting tests/test_transifex.py ___________________
.tox/py35/lib/python3.5/site-packages/_pytest/python.py:571: in _importtestmodule
mod = import_path(self.fspath, mode=importmode)
.tox/py35/lib/python3.5/site-packages/_pytest/pathlib.py:517: in import_path
importlib.import_module(module_name)
/opt/hostedtoolcache/Python/3.5.10/x64/lib/python3.5/importlib/init.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
:985: in _gcd_import
???
:968: in _find_and_load
???
:957: in _find_and_load_unlocked
???
:673: in _load_unlocked
???
.tox/py35/lib/python3.5/site-packages/_pytest/assertion/rewrite.py:171: in exec_module
exec(co, module.dict)
tests/test_transifex.py:16: in
from sphinx_intl import transifex
E File "/home/runner/work/sphinx-intl/sphinx-intl/.tox/py35/lib/python3.5/site-packages/sphinx_intl/transifex.py", line 93
E msg = textwrap.dedent(f"""
E An unsupported version of the Transifex CLI was found.
E Version {TRANSIFEX_CLI_MINIMUM_VERSION} or greater is required.
E Please run the below command if you want to use this action:
E
E $ tx update
E
E """)
E
E
E
E
E
E
E
E ^
E SyntaxError: invalid syntax
=========================== short test summary info ============================
ERROR tests/test_cmd_pot.py
ERROR tests/test_cmd_transifex.py
ERROR tests/test_transifex.py
!!!!!!!!!!!!!!!!!!! Interrupted: 3 errors during collection !!!!!!!!!!!!!!!!!!!!
============================== 3 errors in 0.67s ===============================

Footnotes not rendering as expected in localized version when using myst parser

I have a Sphinx documentation project where I'm writing content in Markdown using the myst parser. In the default English version of the documentation, footnotes are formatted correctly, and I'm getting properly rendered footnotes in the resulting HTML when I build the documentation.

However, I've also created a localized German version of the documentation, and while the translation seems to work fine overall, I'm encountering an issue with footnotes. In the German version, the footnotes are not being converted to the correct HTML format. Instead of seeing the formatted footnotes as in the English version, it appears that the German version is simply printing the Markdown string, like [^1], without converting it to the expected HTML footnote markup.

The .po files look fine, e.g.:

#: ../test.md:1
msgid ""
"Test [^1]"
msgstr ""
"Test [^1]"

I expect that when I build the German version of the documentation, the footnotes should be processed and rendered in the same way as they are in the original English version. Other markdown features also work without interfering with the locales. Any idea what I am missing?

KeyError: 'transifex_project_name' when updating .tx/config

When I was updating the txconfig using

$ sphinx-intl create-txconfig
$ sphinx-intl update-txconfig-resources --transifex-project-name python-35-tw
Traceback (most recent call last):
  ...
  File "/Users/liang/.virtualenvs/pydoc/lib/python3.5/site-packages/sphinx_intl/commands.py", line 536, in update_txconfig_resources
    args = [arg % locals() for arg in args_tmpl]
  File "/Users/liang/.virtualenvs/pydoc/lib/python3.5/site-packages/sphinx_intl/commands.py", line 536, in <listcomp>
    args = [arg % locals() for arg in args_tmpl]
KeyError: 'transifex_project_name'

It failed with KeyError, which the argument should be passed to the function.
A quick survey showed it might be related with using locals() inside list comprehension,

# sphinx_intl/commands.py:536
args = [arg % locals() for arg in args_tmpl]

If I change to

d = locals()
args = [arg % d for arg in args_tmpl]

then the code works.

A demo shows this different behavior in Python 2 and 3.

def print_dict(d):
    print(d)

def main():
    a, b = 3, 4
    print_dict(locals())
    [print_dict(locals()) for i in range(2)]

if __name__ == '__main__':
    main()

# python 2.7
# {'a': 3, 'b': 4}
# {'a': 3, 'i': 0, 'b': 4}
# {'a': 3, 'i': 1, 'b': 4}

# python 3.4 / 3.5
# {'a': 3, 'b': 4}
# {'.0': <range_iterator object at 0x1029851e0>, 'i': 0}
# {'.0': <range_iterator object at 0x1029851e0>, 'i': 1}

My Python packages versions:

Sphinx==1.3.3
sphinx-intl==0.9.7
transifex-client==0.11

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.