themsaid / laravel-langman Goto Github PK
View Code? Open in Web Editor NEWLanguage files manager in your artisan console.
License: MIT License
Language files manager in your artisan console.
License: MIT License
i have users.php files in HE and EN folders, but script say me "Language file users.php not found!".
In the config.php file i not make changes.
'path' => realpath(base_path('resources/lang')),
Laravel 5.1
How to create the issue:
php artisan langman:trans nav.new_item
> Create item
Error:
Undefined index: vendor
Laravel Version: 5.2
Say we have for instance the following language files and keys:
lang/en/users.php [ 'name' => 'Name' ]
lang/en/address.php [ 'city' => 'City', 'zip' => 'Zip code' ]
lang/fr/users.php [ 'name' => 'Nom' ]
lang/fr/address.php [ 'city' => 'Ville' ]
lang/de/users.php [ 'name' => 'Name' ]
We need a command which would synchronize all languages with the same keys.
A translator will not have access to php artisan, so the command missing
will not really help in this case.
That command in that example would:
lang/de/address.php
with all keys,zip
to the file lang/fr/address.php
Of course, that command needs to know which language is our reference (in this example, en
is the reference language), that could be a setting in config for instance and/or could be overridden in the command line.
i'm trying to solve the problem but i think you could do it faster than me , could you please check all tests
Langman creates new files with new keys which are empty.
Problem is that translators who receive those files will have to look into the original language files to know what the original message is before they can translate it.
It would be useful to have a default language instead of an empty string.
There are lots of places where we have messages: controllers, validation, events, etc. All of them are not taken into account, just the views.
This would be fair to incorporate those classes into the sync process.
There should be a section at the end of the README file which mentions the main changes made for each version.
Filesystem::dirname and ressoure_path are not present in laravel 5.1
i will try to get it working on 5.1 and then do a PR
By far not an urgent issue, just thought I should report that running php artisan langman:sync
throws ErrorException : Undefined offset: 2
when "Synchronizing language files..." if you have any php lang file that only returns an empty array.
<?php
return [
//
];
php artisan langman:sync
For easily dealing with translators.
langman:trans command is not translating UTF8 characters (like ş, ğ, ı)
php artisan langman:trans messages.title
Başlık
messages.title:tr was set to "Ba\l\k" successfully.
3rd party packages sometimes allow to publish translation files.
Those file are usually located inside a subfolder of lang. For instance:
lang
|_ en
|_ fr
|_ es
|_ vendor
|_ package1
| |_ en
| |_ fr
| |_ es
|_ package2
|_ en
|_ es
fr
be created in package2 folder?When running sync i get the following
<?php
return [
'0' => '1',
'access' => [
'test' => '',
],
];
the 0 => 1 is always there i am not sure how that's added.
Laravel Version: 5.7.9
PHP Version: 7.1.19
Database Driver & Version: MySQL 5.7.23
When you have a key in a language-file with a .
(e.a. 'No.' in it and run php artisan langman:sync
and a language is missing that key, it doesn't add the key the same way but changes it to:
'No' => [
'' => '',
],
instead of
'No.' => '',
See description
You currently require PHP7, which is way above the requirement set by Laravel itself. Could you update the composer file so that we can still install it?
Instead of keep empty, please take the default locale's translation as default when syncing,It's more convenience for translate.
How will one use the sync command to scan the modules/ folder as well. we have several modules and we would like to sync the translations from the views under modules/Admin/Resources/views
We extended the provider and changed the paths but it wont recognize the 'trans' calls in the views.
Thanks.
When I run twice the command to sync files, I get lots of message on first run which say "message XXX has been added" but I also get those same messages each time I run the command.
When I run the command twice I would only expect an update to my files only the first time, and the second run should see nothing to sync (no message added).
Right?
Is that possible disable mysite.com/langman url on production environment?
I think its a security issue.
php artisan langman:translate users.name
php artisan langman:translate users.name.en
i get no command "translate" it's "trans"
php artisan langman:trans users.name
php artisan langman:trans users.name.en
Language files under sub-directories are not taken into consideration.
e.g.:
/en
/menu
menu.php
The above is valid and can be accessed using __('menu/nav.some-key')
.
However, this package doesn't recognise them.
Add a language file in the file structure above (with some keys).
Then run php artisan langman:show menu/nav
Excepted Result
See the keys and their translations
Actual Result
No keys are shown
Hi
Don't know if it happens on other platforms but it happens on windows.
Verified on a fresh laravel install.
So far, so good.
The issue comes up when I try to add a new translation
The problem is in Manager.php
- fillKeys($fileName, array $keys)
method.
$filePath = $this->path."/{$languageKey}/{$fileName}.php";
: first translation results in C:\Work\www\projects\dummy\resources\lang/C:\Work\www\projects\dummy\resources\lang\en/auth.php
The workaround was $filePath = "{$languageKey}/{$fileName}.php";
. The result is C:\Work\www\projects\dummy\resources\lang\en/auth.php
and new translations were added with success.
The sync command has issues too:
Then added another translation mannualy and tried the missing command
There's a success message but the translation was not added to es/auth.php
The remove command fails too.
Cheers
opening another issue to request support for nested keys (as mentioned in #3, but to keep feature requests separated).
How to create the issue:
php artisan langman:trans nav.new_item
> Create new item
Error:
addslashes() expects parameter 1 to be string, array given
Laravel Version: 5.2
Could be a useful idea an integration with this package https://github.com/kazupon/vue-i18n
I'am using and generate a JS object with https://github.com/martinlindhe/laravel-vue-i18n-generator, but the call of key for translate is some like this $t('message.hello')
and the the workflow for include the key is manual, not like the easy command php artisan langman:sync
.
Example in Vue template file:
<div class="message">
<p>{{ $t('message.hello', {name: 'visitor'}) }}</p>
</div>
It's just an idea, if you need more details let me know ;)
Hi,
I have this lang file e.g
// file lang/users.php
return [
'tips' => [
'one' => 'First tip',
'two' => 'Second tip',
// etc.
]
];
And in a controller or a file inside app directory:
// lang('users.tips') is an array
foreach (lang('users.tips') as $tip) {
// do something with the texts
}
So the problem is that when I use "langman:sync" command, it writes an empty array in tips.
// file lang/users.php
return [
'tips' => ''
];
Is this a bug or an expected behauvior?
Anyway, congrats for the package, it rocks.
$ php artisan langman:missing
Looking for missing translations...
[ErrorException]
Undefined offset: 1
No idea why that happens. I got some vendor files and maybe some files are created in one language and not in the others.
Hi.
I think that it'd be very usefull to auto create files of scanned $allkeysInFiles.
maybe here SyncCommand@syncKeysFromFiles or in other function..
because there are a lot of results found but no new translation file is created!
if you can add it please!
Hi
Found this error while working in a 5.2.31 app and tested in a fresh 5.2.32.
The error only occurs when showing validation. It works ok with auth, passwords, pagination language files.
[2016-05-17 14:20:43] local.ERROR: ErrorException: strstr() expects parameter 1 to be string, array given in C:\Work\www\projects\aa\vendor\symfony\console\Helper\Table.php:398
Stack trace:
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'strstr() expect...', 'C:\\Work\\www\\pro...', 398, Array)
#1 C:\Work\www\projects\aa\vendor\symfony\console\Helper\Table.php(398): strstr(Array, '\n')
#2 C:\Work\www\projects\aa\vendor\symfony\console\Helper\Table.php(256): Symfony\Component\Console\Helper\Table->buildTableRows(Array)
#3 C:\Work\www\projects\aa\vendor\laravel\framework\src\Illuminate\Console\Command.php(339): Symfony\Component\Console\Helper\Table->render()
#4 C:\Work\www\projects\aa\vendor\themsaid\laravel-langman\src\Commands\ShowCommand.php(95): Illuminate\Console\Command->table(Array, Array)
#5 [internal function]: Themsaid\Langman\Commands\ShowCommand->handle()
#6 C:\Work\www\projects\aa\vendor\laravel\framework\src\Illuminate\Container\Container.php(507): call_user_func_array(Array, Array)
#7 C:\Work\www\projects\aa\vendor\laravel\framework\src\Illuminate\Console\Command.php(169): Illuminate\Container\Container->call(Array)
#8 C:\Work\www\projects\aa\vendor\symfony\console\Command\Command.php(256): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 C:\Work\www\projects\aa\vendor\laravel\framework\src\Illuminate\Console\Command.php(155): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 C:\Work\www\projects\aa\vendor\symfony\console\Application.php(791): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 C:\Work\www\projects\aa\vendor\symfony\console\Application.php(186): Symfony\Component\Console\Application->doRunCommand(Object(Themsaid\Langman\Commands\ShowCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 C:\Work\www\projects\aa\vendor\symfony\console\Application.php(117): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 C:\Work\www\projects\aa\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(107): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 C:\Work\www\projects\aa\artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 {main}
Cheers
When you have a key in a language-file with a \'
in it and run php artisan langman:missing
it works okay and you can translate things, but when you run php artisan langman:missing
again, it crashes because langman overwrites the key with \'
and changes it to '
\'
in it. e.a. 'today's posts'php artisan langman:missing
(also works with php artisan langman:trans KEY
) (note: you also cannot use the 'today's posts' as key)php artisan langman:missing
again -> crash and 'today's posts' is changed to 'today's posts'so is this for translation for a single language non-english app, or an app with multiple language selection?
Rename a key across languages.
I noticed that when I use langman artisan command to make an Arabic translation it aborts without adding the translation and without carrying-on to the other languages.
As an overall observation, Arabic is not supported every command (sync, missing, trans...) throws errors when Arabic is around.
add an Arabic translation to to resources/lang/ar folder and use langman.
I want to have the possibility to ignore the default language-files (auth.php, pagination.php, passwords.php, validation.php)
How about a command for purging unused strings in lang files?
There is a potential problem with trans('app.type_' . $type)
kind of translations, as the user will create custom entries in the files... but, still, I think that a command like this would be useful.
Maybe all the custom strings could be placed in files that could be blacklisted from purging at config level.
@themsaid, have you thought about a feature like this?
Sync is ignoring @lang and @choice if they are used just after an HTML tag.
For example: <p>@lang('language.line')</p>
The problem is that the regex is ignoring them because the first part: [^\w|>]
Is that the expected behavior?
I have been playing with the regex in https://regex101.com/r/jS5fX0/2 but I'm not sure how to solve this in the right way.
Hi all thanks a lot, I am new to laravel I want to make site with two languages Arabic and English, how can I switch between using this package, thanks
add --lang option to php artisan langman:missing
so you can specify which language you want to check. Right now the command checks all language files and if you only want to check the English one, you first got to skip all other inputs for other languages
Hi. It's just an idea but I think it could be useful.
-i think the show command
can be improved.
One improvement consists in adding an optional param language
.
php artisan langman:show auth en
/ php artisan langman:show auth.failed en
to show the auth translations for one language. If the language passed does not exists, the show the languages available (maybe another command to show the available languages? )
Another improvement is about how the translations are displayed when you have several languages and/or long strings.
Transposing the data? Display two languages at a time and repeat the header? Setting based ?
With five languages which is not so uncommon in european apps (en, fr, de, es, pt) it becomes a mess on the screen.
Keep up the good work.
Causing the console table to break.
Whenever I add translations in lang files via langman, Langman does not write into files according to PSR-2 standards.
1- It adds one space after "<?php "
2- It does not add line break at the end of array
1- add any translation via langman
Could it be possible? It would be very useful for flash messages.
Steps to reproduce:
php artisan langman:trans labels.bye
When I inject the Manager into a command I'm writing in our Laravel 5.1 based app so I can utilize its methods I am able to successfully do this:
$allViewsKeys = $this->manager->collectFromFiles();
But when I try and do this:
$translationFiles = $this->manager->files();
I get the error:
[ErrorException]
Missing argument 2 for Themsaid\Langman\Manager::Themsaid\Langman{closure}()
But is seems all our system variables are in the places the module is expecting the find them.
When I click Scan, I got this error in the console:
langman.js:42763 Uncaught TypeError: Cannot read property 'Login' of undefined
at Vue$3.addNewKey (langman.js:42763)
at Vue$3.boundFn [as addNewKey] (langman.js:33189)
at _.forEach.key (langman.js:42835)
at arrayEach (langman.js:14459)
at Function.forEach (langman.js:23281)
at Object.$.post.done.response (langman.js:42834)
at fire (langman.js:6979)
at Object.fireWith [as resolveWith] (langman.js:7109)
at done (langman.js:12934)
at XMLHttpRequest. (langman.js:13176)
Just click the 'Scan' button
I have a very large translation database and translating it now is quite difficult even with this awesome package. It would be nice if the text that I need to translate is shown in the already available translation, for example the default language of the app (app.locale config).
So if I have my app with default language in English, than I would like to translate it to some other language. But I need to see what the actual text is I need to translate in the default app language, because the key is not self explanatory enough.
It would be really nice if this would be an option.
Hello
Can you update composer.json to allow 5.3 illuminate components please ?
Cheers
Hi,
I would like to create a lang file(or if exists) and add a new key with translated text in one just command.
for example :
php artisan langman:trans users.name --lang=en --text="this a translation"
is that possible?
Regards
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.