salamek / gettexttranslator Goto Github PK
View Code? Open in Web Editor NEWGettext Translator is tool that enables simple and user friendly translation of your texts via panel in debug bar.
License: BSD 3-Clause "New" or "Revised" License
Gettext Translator is tool that enables simple and user friendly translation of your texts via panel in debug bar.
License: BSD 3-Clause "New" or "Revised" License
In our project we have separated modules and in order to prevent string clashes by merging all files to one instance of Gettext
translator by using addFile
we are creating instance of Gettext per module.
And this led to production-only bug as each Gettext
translator uses the same cache directory-<lang>
.
How to reproduce:
$translator = new Gettext($session, $storage, $response);
$translator->addFile($path, 'messages);
$translator->setProductionMode(true);
echo $translator->translate('Foo'); # Translated as "Goo"
$translator2 = new Gettext($session, $storage, $response);
$translator2->addFile($path, 'messages);
$translator2->setProductionMode(true);
echo $translator2->translate('Foo'); # Translated as "Bar", however "Goo" from cache obtainedfa
Considering two solutions:
The first way seems more plausible as it also prevents related issues (for example with new strings in session).
I have encounered weird behaviour of Gettext::translate
Usage:
{_'%d images were uploaded and inserted.', 1}<br >
{_'%d images were uploaded and inserted.', 2}<br >
{_'%d images were uploaded and inserted.', 5}
Template:
msgid "%d images were uploaded and inserted."
msgid_plural "%d images were uploaded and inserted."
msgstr[0] ""
msgstr[1] ""
Translation:
msgid "%d images were uploaded and inserted."
msgid_plural "%d images were uploaded and inserted."
msgstr[0] "%d image was uploaded and inserted."
msgstr[1] "%d images was uploaded and inserted."
What I get:
1 image was uploaded and inserted.
2 image was uploaded and inserted.
5 image was uploaded and inserted.
It seems to me that the translate function is trying to use the argument as a index into translation array instead of clasifying which group it is and then using the group index.
Is that an error, I am using something not supported or the syntax for this usage is weird?
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.