Code Monkey home page Code Monkey logo

Comments (22)

eldor avatar eldor commented on June 22, 2024 1

Try release 1.0.4 it have a merge option on scan command

from laravel-translation.

eldor avatar eldor commented on June 22, 2024 1

Ok, i see, then it makes sense.
Will look into a solution to support this.

from laravel-translation.

eldor avatar eldor commented on June 22, 2024

Thx for your comment.
The issue is there is no option at the moment to separate json translations from system translations in the poeditor interface.
I have some options to try out, but if you have a suggestion you are more than welcome to discuss it here.

from laravel-translation.

kasperhartwich avatar kasperhartwich commented on June 22, 2024

Maybe a seperate command to import the php files to the json files could be an idea.
It should be possible to import the files by using laravels Loader.

from laravel-translation.

kasperhartwich avatar kasperhartwich commented on June 22, 2024

Could easily be better structured, but i used this to get the translations:

Arr::dot(collect(\Illuminate\Support\Facades\File::files(base_path('resources/lang/en')))->mapWithKeys(function($file) {
  $group = str_replace('.php', '', $file->getFilename());
  return [
    $group => 
    (new \Illuminate\Translation\FileLoader(
      new Illuminate\Filesystem\Filesystem(),
            base_path('resources/lang')
    ))->load('en', $group)
  ];
})->toArray());

from laravel-translation.

eldor avatar eldor commented on June 22, 2024

Yes, but the problem is not in the scan, it already scans those files, the problem is with POEditor and how to write it back in different folders and files.

The solution is to change your system translations in /resources/lang/en/auth.php from:

'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',

to:

'throttle' => __('too many login attempts. Please try again in :seconds seconds'),

Then it will on next scan it will add it to the translation sync and you are all good.

I'll update the README soon.

from laravel-translation.

kasperhartwich avatar kasperhartwich commented on June 22, 2024

Ohh.. Is that why it removes the translations i imported, when doing a new scan?

from laravel-translation.

eldor avatar eldor commented on June 22, 2024

Good question, do you mean in POEditor or in Laravel project?
A new scan creates a new base_language file and that is was is getting uploaded.

from laravel-translation.

kasperhartwich avatar kasperhartwich commented on June 22, 2024

Ohh. That's why. As it is primary uploading terms, wouldn't it be smarter to merge with current one and then upload? In that way you can create terms without using then in the application.

from laravel-translation.

eldor avatar eldor commented on June 22, 2024

Good idea, will look into that.

from laravel-translation.

kasperhartwich avatar kasperhartwich commented on June 22, 2024

Cool. I also often experience that code gets outcommented, removed or added from different branches, so they are sometimes there and then not. The result of that would be terms getting deleted and added all the time.

from laravel-translation.

eldor avatar eldor commented on June 22, 2024

You always have to do a scan for translations then the file will always be updated.
If I do a merge, old keys will be keept and never cleaned up. It will also fill up in POEditor.
We only use translation scan on master branch before deploying.

from laravel-translation.

kasperhartwich avatar kasperhartwich commented on June 22, 2024

But you can delete olds keys manually on POEditor? And if you wait to scan upon deployment, you could get translations in production that has not been translated.

from laravel-translation.

kasperhartwich avatar kasperhartwich commented on June 22, 2024

There is one slight problem. If the key exists, it overrides the translation. So if the translation has been changed at POEditor, it will be changed backed to default value in the json file.

from laravel-translation.

eldor avatar eldor commented on June 22, 2024

Its expected behavior, POEditor always have priority, if you choose to do an upload/download.
Otherwise im misunderstand ;)

from laravel-translation.

kasperhartwich avatar kasperhartwich commented on June 22, 2024
  1. Scan and upload to POEditor
  2. Change string at POEditor.
  3. Download strings from POEditor.
  4. Scan and merge.

Then the translated string from POEditor is overwritten by the string from the code.

from laravel-translation.

eldor avatar eldor commented on June 22, 2024

But why do you need the base_language strings translated in PoEditor?
They are by default correct from the code? or are you using this format group.text instead of full strings like Your pasword is incorrect ?

from laravel-translation.

kasperhartwich avatar kasperhartwich commented on June 22, 2024

First, they are only correct if the developer speaks correct english.
Secondly, for this project; yes i am using keys and not sentences to pass to the POEditor, so here they are called f.ex 'auth.password.incorrect' like laravel default behaviour.

from laravel-translation.

kasperhartwich avatar kasperhartwich commented on June 22, 2024

In general i don't see why new translations should ever overwrite the ones already in the translation files.

from laravel-translation.

eldor avatar eldor commented on June 22, 2024

Try version 1.0.5 it only add new keys when using the --merge option

from laravel-translation.

eldor avatar eldor commented on June 22, 2024

Hi @kasperhartwich have you looked at the new version and does it fix your merge issues?

from laravel-translation.

danijelk avatar danijelk commented on June 22, 2024

Feel free to reopen if there is anything else.

from laravel-translation.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.