amiranagram / localizator Goto Github PK
View Code? Open in Web Editor NEWScan your Laravel project and generate language files ready to translate in language(s) of choosing.
License: Other
Scan your Laravel project and generate language files ready to translate in language(s) of choosing.
License: Other
Hi. Thank you for this amazing package.
Is there any way that we can use lang.php instead of lang.json?
the lang folder is no longer under resources, so the following line in helpers.php is incorrect for laravel 9.x installs.
return resource_path('lang'.($path !== '' ? DIRECTORY_SEPARATOR.$path : ''));
First of all, thanks a lot for this package, it saved me tons of time!
I was wondering if the command could be used on a CI, and would fail (e.g. return a non 0 code) if it finds new keys to translate, without adding them.
The command signature could be (to discuss):
php artisan localize fr --dry-run --ci
--dry-run
would instruct it to return the number of untranslated terms found by comparing what is already inside json/php files, and what the command was about to add. So the command will not really add the terms, just show what it is about to add.
--ci
would return a non 0 code if some translations have been added (if not using in pair with --dry-run
), or if some translations would have been added (if used with --dry-run
). In this case we could prevent deploying in production pages not fully translated (at least I would use it all the times).
I could give it a try if you find this feature useful to add to the package.
When a path-based namespace is used, e.g. {{ __('module/submodule/messages.Test')}} and a file xx/module/submodule/messages.php exists with keys
<?php
return [
'Test' => 'Test Message',
'Another' => 'Another Message',
];
After running php artisan localize xx the file is overwritten with empty key values
<?php
return [
'Test' => '',
'Another' => '',
];
Hi. I have encoutered an issue with dot separated word/acronym. For example, @lang('F.A.Q')
will generate a F.php file.
/* F.php */
<?php
return [
'A' => [
'Q' => '',
],
];
Since Laravel use dot syntax to map the language files. How do I ignore this specific word from being outputted as a file?
When translating the following test-strings:
{{__('This is a "Test", followed by some text')}}
{{__("This is another \"Test\", followed by more text")}}
They both result in wrong keys. They keys are as follows:
"This is a \"Test": "",
"This is another \"Test": "",
I was about to do a pull request but i cant seem to figure out the regexp rules in the parser... Its not my strong suit....
Anyway here is a link to the regepx rules and tester, would really appreciate some help :)
Tried to install with that command:
composer require --dev amirami/localizator
Error:
Could not find a version of package amirami/localizator matching your minimum-stability (stable). Require it with an explicit ve
rsion constraint allowing its desired stability.
require [--dev] [--dry-run] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--fixed] [--no-suggest] [--no-progress] [--no-update] [--no-install] [--no-audit] [--audit-format AUDIT-FORMAT] [--update-no-dev] [-w|--update-with-dependencies] [-W|--update-with-all-dependencies] [--with-dependencies] [--with-all-dependencies] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--] [<packages>...]```
Hey, I used this package also for inertiajs with the https://github.com/xiCO2k/laravel-vue-i18n package.
I added $t to the pattern and it works but the regex don't check for examples like this:
$t(
'some random translatable message'
)
I adjusted the regex and asking if I should make pr with that, if you planned support for js?
I want to ignore all files in the resources/views/vendor folder.
Hello.
Is it possible that the extraction script automatically deletes the keys that no longer exist?
Example: A .blade.php file contained a string 'test'. This string doesn't exist anymore (it has been deleted from balde.php). Is it possible that it is automatically removed from the lang files so that we have a version that is always up to date and does not have a key that no longer exists?
Hello,
thank you for this nice package.
in the configuration file i have default=true and when i run the command:
php artisan localize de
In the ressource/lang there is just json file not .php ?
I have missing something ?
Excellent package!
A minor change needed, when generating lists for languages other than the default one, keep the translated string empty.
Example
default lang = en
__('Account settings')
en.json
"Account settings": "Account settings",
de.json
"Account settings": "",
instead of
de.json
"Account settings": "Account settings",
Hi thanks for this package, it's pretty great.
Laravel comes with a bunch of messages used at core for validation, auth, pagination, and passwords, we can get a default set of languages using: https://github.com/Laravel-Lang/lang
if we use something like trans("validation.color")
and then run
php artisan localize en --remove-missing
the validation.php file will be emptied, this probably can be solved using search.dirs
in the config, any idea what the dirs should be? I don't think it would be as easy as that actually. for instance $this->translator->get
was used at vendor/laravel/framework/src/Illuminate/Validation/Concerns/FormatsMessages.php
Anyways I think this should be supported by default maybe.
in composer.json require
"illuminate/contracts": "^8.0"
it's mandatory ?
because it's not working on laravel 6.x LTS
Not working with PHP 8
Is there any chance that this package will work with php 7.3 ?
Hey there - are there any plans on supporting Laravel 11?
Hello,
I'm using the laravel-vue-i18n package.
I put my configuration file like this :
'search' => [
/**
* Directories which should be looked inside.
*/
'dirs' => [
'app',
'resources',
'routes',
],
/**
* Subdirectories which will be excluded.
* The values must be relative to the included directory paths.
*/
'exclude' => [
'vendor/cookie-consent',
],
/**
* Patterns by which files should be queried.
* The values can be a regular expression, glob, or just a string.
*/
'patterns' => ['*.php', '*.vue'],
/**
* Functions that the strings will be extracted from.
* Add here any custom defined functions.
* NOTE: The translation string should always be the first argument.
*/
'functions' => ['__', 'trans', '@lang', 'trans_choice', '$t']
],
And yet, it doesn't bring out the values in me, such as:
<label for="new-message" class="form-label">{{ $t('Add a new message for this travel') }} :</label>
I also had to ignore the spatie/laravel-cookie-consent
package because it crashes due to the following strings:
{!! trans('cookie-consent::texts.message') !!}
Thank you for your help
I have a php-cs-fixer rule that automatically fix my files to add the declare(strict_types=1);
directive on top of my files, including translations files (auth.php, validation.php, ...).
The package keeps removing them, when I want to keep them. Is it possible to keep this directive?
I am not sure if this is something others would want to make use of:
Scenario:
To simplify the translation task I want to be able to send a single file to my translator in json format.
lang/xx.json
(xx is the short code for the target language)lang/xx.json
Current solution:
I can see from the source code that by overriding the binding of localizator.writers.default
in my AppServiceProvider
I am able to achieve this
$this->app->bind('localizator.writers.default', JsonWriter::class);
I have put the above solution in place, but it would be nice to have this as an option in the configuration?
It works well for @lang()
but does not add the translations for @choice()
To check if choice()
is parsed as well
Hi @musmanikram . Thanks for the great localization package.
For key based translations, when i have this;
'401' => [
'title' => '401 - Unauthorized',
'message' => 'Sorry, you are not authorized to view this page.',
],
and then run localize
it is being converted to this;
401 => [
'title' => '401 - Unauthorized',
'message' => 'Sorry, you are not authorized to view this page.',
],
Changing string keys into integers causes issues for me with BabelEdit because it requires all keys be strings.
Not sure if it's just a side effect of the key conversion, but the indentation also gets messed up;
'default' => [
'title' => 'Error Response',
'message' => 'Sorry, something went wrong. Please go to the start page.',
],
404 => [
'title' => '404 - Not Found',
'message' => 'The requested page could not be found. Please go to the start page.',
],
500 => [
'title' => '500 - Internal Server Error',
'message' => 'Please try again later.',
],
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.