solaluset / i18nice Goto Github PK
View Code? Open in Web Editor NEWThis project forked from danhper/python-i18n
A nice i18n library for Python
Home Page: https://pypi.org/project/i18nice/
License: MIT License
This project forked from danhper/python-i18n
A nice i18n library for Python
Home Page: https://pypi.org/project/i18nice/
License: MIT License
Hello,
I'm currently using your i18n fork as base for one of my programs.
I'm trying to add the git dependency in my requirements.txt
file, but I cannot get that to work:
requirements.txt:
command_runner>=1.4.1
cryptidy>=1.1.0
python-dateutil
ofunctions.logger_utils>=2.3.0
ofunctions.misc>=1.5.2
ofunctions.process>=1.3.0
ofunctions.threading>=2.0.0
python-pidfile>=3.0.0
pysimplegui>=4.6.0
requests
ruamel.yaml
psutil
git+https://github.com/Krutyi-4el/python-i18n/archive/master.zip
When I run pip install -r requirements.txt
, I get the following:
Collecting git+https://github.com/Krutyi-4el/python-i18n/archive/master.zip (from -r requirements.txt (line 13))
Cloning https://github.com/Krutyi-4el/python-i18n/archive/master.zip to c:\users\orsiris\appdata\local\temp\pip-req-build-1ax6s006
Running command git clone --filter=blob:none --quiet https://github.com/Krutyi-4el/python-i18n/archive/master.zip 'C:\Users\Orsiris\AppData\Local\Temp\pip-req-build-1ax6s006'
remote: Not Found
fatal: repository 'https://github.com/Krutyi-4el/python-i18n/archive/master.zip/' not found
error: subprocess-exited-with-error
× git clone --filter=blob:none --quiet https://github.com/Krutyi-4el/python-i18n/archive/master.zip 'C:\Users\Orsiris\AppData\Local\Temp\pip-req-build-1ax6s006' did not run successfully.
│ exit code: 128
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× git clone --filter=blob:none --quiet https://github.com/Krutyi-4el/python-i18n/archive/master.zip 'C:\Users\Orsiris\AppData\Local\Temp\pip-req-build-1ax6s006' did not run successfully.
│ exit code: 128
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
I've also tried URL https://github.com/Krutyi-4el/python-i18n/archive/refs/heads/master.zip
which gives the same results.
Since the original python-i18n
isn't developped anymore, would you mind to make a git and PyPI release ?
As a side question, since you don't own the python-i18n
namespace on PyPI, would you consider asking @danhper to take owernship of the package, so a new release can be done in the original namespace ?
Best regards.
PS: Thanks for the efforts you put into the project
I've used the original python-i18n in a couple of my programs for Windows and Linux.
I'm compiling my programs with Nuitka python compiler.
When running compiled versions, I get the following error (on a couple of target machines only):
Traceback (most recent call last):
File "/tmp/onefile_1415848_1679656173_703364/npbackup/__main__.py", line 517, in main
File "/tmp/onefile_1415848_1679656173_703364/npbackup/__main__.py", line 336, in interface
File "/tmp/onefile_1415848_1679656173_703364/npbackup/core/i18n_helper.py", line 46, in _t
File "/tmp/onefile_1415848_1679656173_703364/i18n/translator.py", line 28, in t
File "/tmp/onefile_1415848_1679656173_703364/i18n/translator.py", line 44, in translate
File "/tmp/onefile_1415848_1679656173_703364/i18n/translator.py", line 18, in format
File "/tmp/onefile_1415848_1679656173_703364/string.py", line 161, in safe_substitute
TypeError: expected string or bytes-like object
I can guarantee the the Python code is correct, since it works in most scenarios, except for a couple of machines.
I've hunted down the error to multiple translation files, the first not being loaded properly.
For what it's worth, having switched to your version of python-i18n, my compiled programs run flawlessly everywhere.
Best regards.
Hello,
I wanted to know, can we add a folder of translation then do for example:
message.translate("Administration:LANGUAGES_LIST", message.guild.id, { LANGUAGES: languages.join("\n- ") })
See: this & this and this for example(JavaScript example but I mean it for this module in Python
)
Best Regards.
test
Hi!
I've noticed a weird recursion error when using your improved version of python-i18n (I love what you did btw, thanks for the work).
Basically, in the t
function, when a translation key cannot be found, your code checks if the used language is the same as the fallback one. If not, then it tries to find the translation with the fallback language. And that works fine as long as you do have a fallback language.
BUT if the fallback language is set to None
, then the condition at line 20 is always met (because locale
cannot be None), and t()
is called back with locale=None
, which forces to use the locale
config value, which is again different than the fallback value.
A simple fix should be to check if config.get('fallback')
is None, and if it is, raise a proper error (a KeyError or anything more intuitive).
Hope this helps!
First, I want to thank you first for taking on the maintenance of the original python-i18n
package and add more functionality to it.
This simple, lightweight, and user-friendly i18n tool saves me a lot of time. Salute.
Here I'd like to request a feature addition to enhance the package's capabilities. Specifically, the support for localized key references.
An example written in JSON is provided as follows:
{
"en": {
"DUMMY_1": "dummy1",
"DUMMY_2": "dummy2",
"MENU_A_DUMMY": "${DUMMY_1} and ${DUMMY_2}",
"MENU_B_DUMMY": "${DUMMY_1}"
}
}
And the corresponding expected result will be:
i18n.t("MENU_A_DUMMY") # Output: dummy1 and dummy2
With a special syntax (${}
here, could be replaced with any other delimiters), it would be possible to reference existing localized keys within other translations.
The proposed approach offers two significant advantages: interface flexibility through referencing multiple localized keys within a single translation, allowing diverse interfaces that are easily modifiable in the future, and translation reusability, minimizing redundancy and improving maintenance efficiency.
I believe adding support for localized key references would improve the package's utility, especially for projects with complex translation requirements.
Thank you for considering this enhancement request.
Many thanks for your work on this library!
I have found a small regression since when static references were introduced.
Steps to reproduce:
a) i18n.set("on_missing_placeholder", "error")
b) have a translation string in a .yml with "%%" such as the following: Hello world ! %% %{xyz}
c) a ValueError
from Python is then raised when trying to use i18n.t
-- it looks like the problem is that %%
gets converted to %
during expand_static_refs
in formatters.py
Героям слава!
Hi @Krutyi-4el,
I have recently switched to i18nice
from python-i18n
.
Everything is working fine, thank you for keeping the project alive.
Now, I would like to produce a conda recipe for the project I'm working on: as all the dependencies should be available on a conda channel, I am planning to create a recipe for i18nice
too.
I am opening this issue to check whether you are ok with that.
Let me know!
Thanks for your attention! 🙏
Hello,
I'm using a file with generic translations, like 'yes', 'no' etc.
I've struggled to find why I got the following error:
File "C:\GIT\my_program\my_program.py", line 250, in main
print(_t("generic.up_to_date"))
File "C:\GIT\my_program\i18n\translator.py", line 65, in t
resource_loader.search_translation(key, locale)
File "C:\GIT\my_program\i18n\resource_loader.py", line 117, in search_translation
recursive_search_dir(namespace, '', directory, locale)
File "C:\GIT\my_program\i18n\resource_loader.py", line 125, in recursive_search_dir
load_translation_file(os.path.join(directory, seeked_file), root_dir, locale)
File "C:\GIT\my_program\i18n\resource_loader.py", line 80, in load_translation_file
load_translation_dic(translations_dic, namespace, locale)
File "C:\GIT\my_program\i18n\resource_loader.py", line 95, in load_translation_dic
translations.add(namespace + key, value, locale)
TypeError: can only concatenate str (not "bool") to str
Found out that using words yes
or no
words in translation files will directly transform those to booleans, leading to that error.
I've replaced my entries from
en:
yes: Yes
no: No
to
en:
_yes: Yes
_no: No
Obviously, this solves my issue.
Nevertheless, I'm quite sure that keys should never be translated, am I right ?
The project currently lacks a py.typed marker file, which is required to declare the project as PEP 561 compliant. This file is essential for proper type checking and type hinting support when the project is used as a dependency in other Python packages.
An empty py.typed
marker file could be added to the project's root directory, along with one line change in setup.py
. This shall enable type checkers and IDEs to recognize the project as a valid type hint provider.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.