GithubHelp home page GithubHelp logo

Purge unused strings about laravel-langman HOT 8 OPEN

themsaid avatar themsaid commented on July 24, 2024
Purge unused strings

from laravel-langman.

Comments (8)

themsaid avatar themsaid commented on July 24, 2024

Regarding the command for purging strings, I'm not quite sure if we can consider all the cases to check for an unused translation line, do you have any ideas on how to guarantee?

from laravel-langman.

joelcuevas avatar joelcuevas commented on July 24, 2024

Not sure either, but thinking on my workflow:

Hypothetically I would blacklist on config/langman.php files like resources/lang/en/status.php where things like ticket_open should be. This kind of translations are the ones that I use with trans('status.ticket_' . $status). In this files we should never assume that a string is not longer used (because we don't know) and live with it.

With the rest of the files, I would simply search all the translations that do not have an entry on Manager::collectFromFiles result and remove them, maybe with a preview and a prompt.

If on your project you're unable to separate translation keys like the ones on the "status" example from the normal keys, well, maybe you are not a candidate for a "purge" command, and you should continue using the rest of the commands as usually.

Too drastical? Are you thinking on more scenarios?

from laravel-langman.

themsaid avatar themsaid commented on July 24, 2024

Well I assume such command can be useful if you know what you're doing :) If you can PR such thing I'd gladly consider merging.

from laravel-langman.

joelcuevas avatar joelcuevas commented on July 24, 2024

Perfect! I think I could have something by the next week for you to review.

from laravel-langman.

themsaid avatar themsaid commented on July 24, 2024

πŸ‘ :)

from laravel-langman.

morksinaanab avatar morksinaanab commented on July 24, 2024

Have you guys been able to add this? I haven't installed langman yet, but i was indeed looking for the feature to purge unused strings.

Isn't it something like:

  1. 'fake' remove all keys keep them in a map,
    2 run the find missing translation keys function keep that in a map,
  2. remove all found in 2 from 1 > resulting in a list of unused keys to remove?

(probably what joelcuevas is referring to, and indeed variable ones are harder anyway, the would not pop up in step 2 then anyways)

If there isn't another package that has this, and you are not continuing on this, i might take a shot at it?

from laravel-langman.

Gummibeer avatar Gummibeer commented on July 24, 2024

Couldn't the variable Part be solved by a preg_match!?
And Display all Keys that have no real usage but matched by a variable usage to the User.

from laravel-langman.

muisit avatar muisit commented on July 24, 2024

#100 implements a --unused flag for the Show command that can give you a list of all keys that are not actively found in your project files. You can use the Remove command to remove those keys.

You can then script this to filter the list of unused keys with a known list of keys to retain anyway and remove the rest.

from laravel-langman.

Related Issues (20)

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.