Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use rspolib instead of polib #225

Open
1 task done
mondeja opened this issue Mar 9, 2022 · 3 comments
Open
1 task done

Use rspolib instead of polib #225

mondeja opened this issue Mar 9, 2022 · 3 comments
Labels
enhancement New feature or request performance

Comments

@mondeja
Copy link
Owner

mondeja commented Mar 9, 2022

Looks like possible and should improve performance. See https://launchpad.net/pygettextpo

  • How to know if libgettextpo is available? Run ctypes.util.find_library("gettextpo") in setup.py. If returns None is not available.

To read PO files without defined charset "MIME-Version: 1.0\\n"\n"Content-Type: text/plain; charset=utf-8\\n" must be added to the headers or the next error will be raised:

Error
>>> gettextpo.PoFile('example.po')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
gettextpo.error: Charset missing in header.
Message conversion to user's charset will not work.

It seems that would fix #153

Example

Input

#
msgid ""
msgstr ""
"Project-Id-Version: Python 3.8\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-10-16 21:42+0200\n"
"PO-Revision-Date: 2021-08-02 19:31+0200\n"
"Last-Translator: \n"
"Language-Team: python-doc-es\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"Generated-By: Babel 2.9.1\n"

msgid ""
"Support for common temperature sensors (eg, common thermistors, "
"AD595, AD597, AD849x, PT100, PT1000, MAX6675, MAX31855, MAX31856, "
"MAX31865, BME280, HTU21D, and LM75). Custom thermistors and custom "
"analog temperature sensors can also be configured."
msgstr ""
"支持常见的温度传感器(例如,常见的热敏电阻、AD595、AD597、AD849x、PT100、PT1000、MAX6675、MAX31855、MAX31856、MAX31865、BME280、HTU21D和LM75)。还可以配置自定义热敏电阻和自定义模拟温度传感器。"

Code

>>> po = gettextpo.PoFile('input.po')
>>> po.write('output.po')

Output

#
msgid ""
msgstr ""
"Project-Id-Version: Python 3.8\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-10-16 21:42+0200\n"
"PO-Revision-Date: 2021-08-02 19:31+0200\n"
"Last-Translator: \n"
"Language-Team: python-doc-es\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"Generated-By: Babel 2.9.1\n"

msgid ""
"Support for common temperature sensors (eg, common thermistors, AD595, "
"AD597, AD849x, PT100, PT1000, MAX6675, MAX31855, MAX31856, MAX31865, BME280, "
"HTU21D, and LM75). Custom thermistors and custom analog temperature sensors "
"can also be configured."
msgstr ""
"支持常见的温度传感器(例如,常见的热敏电阻、AD595、AD597、AD849x、PT100、"
"PT1000、MAX6675、MAX31855、MAX31856、MAX31865、BME280、HTU21D和LM75)。还可以"
"配置自定义热敏电阻和自定义模拟温度传感器。"
@mondeja mondeja added enhancement New feature or request performance labels Mar 9, 2022
@mondeja
Copy link
Owner Author

mondeja commented Oct 14, 2022

I've done some tests in a local branch. Seems that the current implementation of the library is not enough complete. Create the same interface of polib using the library at C level would be the greatest improvement.

@mondeja
Copy link
Owner Author

mondeja commented Feb 19, 2023

After the developing of md-ulb-pwrap I'm thinking that the best option to optimize the usage of polib is rewriting the library as a CPython extension with Rust.

@mondeja mondeja changed the title Use pygettextpo instead of polib if libgettextpo is available Use an optimized low level PO parser library Feb 19, 2023
@mondeja mondeja added this to the v1.2.0 milestone Mar 7, 2023
@mondeja mondeja removed this from the v1.2.0 milestone Mar 7, 2024
@mondeja
Copy link
Owner Author

mondeja commented Mar 7, 2024

I've written rspolib some months ago, so use that.

@mondeja mondeja changed the title Use an optimized low level PO parser library Use rspolib instead of polib Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request performance
Projects
None yet
Development

No branches or pull requests

1 participant