vemcogroup / laravel-translation Goto Github PK
View Code? Open in Web Editor NEWTranslation package for Laravel to scan for localisations and up/download to poeditor
License: MIT License
Translation package for Laravel to scan for localisations and up/download to poeditor
License: MIT License
When I have a translation like this:
__('Subsequently click on \'scan a barcode\', after which the camera will activate, and point the camera at the QR code.')
The translation will be created is:
"Subsequently click on \\'scan a barcode\\": "Subsequently click on \\'scan a barcode\\"
If I remove the comma from the translation, like this:
__('Subsequently click on \'scan a barcode\' after which the camera will activate, and point the camera at the QR code.')
Then the translation is correct:
"Subsequently click on \\'scan a barcode\\' after which the camera will activate, and point the camera at the QR code.": "Subsequently click on \\'scan a barcode\\' after which the camera will activate, and point the camera at the QR code."
Hi,
Very nice packages. Makes translating the site a alot easier.
I have an issue with a test like:
If you don't no what
As a key it's added with \ in front of the quote. This results in a json key that isn't found in the website and doens't get translated.
Kind regards,
Erwin
This package is amazing, simple and easy to use - so thank you for that! :)
But we have found a problem using it on larger projects, due to the implementation of the upload method. The command php artisan translation:upload
will upload the translations by https://api.poeditor.com/v2/projects/sync
.
This will sync your terms and delete the ones that are no longer in your translation file. This is a problem, for us, because it is not unusual to work on two features at the same time.
Feature 1, is being developed and a few terms are added to the project. A developer will push the terms via php artisan translation:upload
and the new terms he has added are now uploaded to POEditor for translators to work on. The feature is not released yet.
Feature 2, is being developed simultaneously and another developer now pushes his new translations. Translations from feature 1 are now deleted due to the syncing mechanism because the two branches are both ahead.
This is taken from POEditor API documentation under Sync Terms;
Please use with caution. If wrong data is sent, existing terms and their translations might be irreversibly lost.
Would it be possible to utilise the "add terms" instead of syncing as the default upload method? Of cause it should be possible to sync translations, but I find this dangerous due to the way POEditor has implemented this feature.
We have lost a few translations like this unfortunately.
Hello!
I made a PR to fix the following issues:
trans(
'group.message',
['fdsfd']
);
The PR: #9
Hello all,
Say I have a translation in my source code which is formatted like this:
trans(' with :assets', ['assets' => $assets]); // Notice the whitespace prefixing the translation
In the POEditor interface, when translating this sentence to another language, the aforementioned whitespace should remain. Which is perfectly fine and well-handled by POEditor. It's even giving you a visual hint about this whitespace. Example in French:
However, when downloading translations using the translation:download
command, all translations are trimmed. Excerpt from the resulting fr.json
file:
" with :assets": "avec :assets",
Looks like it's on-purpose: src/Translation.php#L127. Why such trimming?
Thank you in advance!
Hi!
I'm having problems with slashes in my terms, like when I have html tags.
I would suggest adding JSON_UNESCAPED_SLASHES
in this line.
Thank you for cool package.
I applied this package to my project and the result is very good.
Except one thing that package scans only *.php
and *.vue
.
How about the functionality which allows user can manually add files or directories to scan?
something like...
# config/translation.php
...
'extra_files' => [
resource_path('js/something.js'),
resource_path('scripts/*.js'),
],
...
I thought that it would be very convenient if this kind of functionality is available.
Thank You.
Hi there
Thanks for this convenient package.
I added the compsoer package, configured everything and wanted to download our POEditor translations. It kicks off after php artisan translation:download
with Preparing to download languages
and all looks good but then it fails with trim() expects parameter 1 to be string, array given
.
I checked where and it is in the Translation.php
line 123.
I dumped what is tried to be trimed here, and the input entry is for example
array:1 [
"teams.tab_button.my" => "My Teams"
]
Isn't that correct? Key and Value as we prepared.
Any hint on what the problem might be would be awesome.
Thanks a lot in advance
PR #15 addresses only one of two use case I have.
Another use case which is more difficult to solve is translations of long or multi-line strings e.g.:
__("Part 1 of a long string.\n" .
"Part 2 of a long string.")
You could e,g. include the opening and closing quotations, and then do eval("return " . $match . ";")
which will work on the above example, but (obviously) use of eval
is potentially dangerous.
Note: In the above example we could have coded it (inconsistently but for good reasons) in a way which would break #15:
__("Part 1 of a 'long' string.\n" .
'Part 2 of a "long" string.')
I guess we could probably code this into a regex \(\s*(?:*'(.*)'|"(.*)")(?:\s*\.\s*(?:*'(.*)'|"(.*)"))*\s*\)
. See https://www.phpliveregex.com/p/FQQ for a non-working example (which doesn't handle (say) 3 or more lines - but we can probably make this work somehow).
__(<<<XYZ
Line 1 of a multi-line string.
Line 2 of a multi-line string.
XYZ);
(Obviously) this is difficult to do a regex for, and performance is likely to be impossibly slow if we don't use regex. So this form is probably not sensible to support.
Hello,
First of all thx for your awesome-package.
Sadly I've encountered a bug recently:
When running:
php artisan translation:upload --scan
All my english-translations are replaced by the translation-keys.
Before it always just scanned the repo for new translation-keys and added them to poeditor without changing the translations.
Laravel-version: 10
package-version: 3.0.8
Best Regards,
Del
Hi, Laravel 9 packs symfony/finder v6.0.3 so can not be installed, a small change in composer.json line 23 needed
- vemcogroup/laravel-translation[3.0.3, ..., 3.0.6] require symfony/finder ^4.3|^5.0 -> found symfony/finder[v4.3.0-BETA1, ..., 4.4.x-dev, v5.0.0-BETA1, ..., 5.4.x-dev] but the package is fixed to v6.0.3 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
I added translation functions from kazupon/vue-i18n to my config/translation.php
as follows:
'functions' => ['__','$t','this.$t'],
However, the scan didn't catch any translation strings from my Vue components. From a bit of testing, it seems to be an issue with the $ symbol. Is there any way I could make this work?
Thanks!
When importing it perfectly scan the application, but it does not import the already existing translations in /resources/lang/en. Maybe it should?
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.