Comments (8)
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.
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.
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.
Perfect! I think I could have something by the next week for you to review.
from laravel-langman.
π :)
from laravel-langman.
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:
- 'fake' remove all keys keep them in a map,
2 run the find missing translation keys function keep that in a map, - 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.
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.
#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)
- πCalling for help HOT 4
- Langman not compitable with laravel 8, HOT 5
- php 8 support HOT 1
- How we can use it in a project multilang Ar En? HOT 1
- Lang files are not PSR-2 HOT 3
- Disable URL on production HOT 2
- langman:sync autocreate
- Create lang file dynamically
- Utf8 Character Translation Not Working
- key with ' in it, breaks it
- Ignore files
- key with '.' in it, creates nested key
- Empty array on lang file throws offset error when syncing HOT 2
- Scan Error - Cannot read property 'Login' of undefined
- Specify language for missing
- Arabic (ar) support
- Lang files in sub-directories of the app not handled (non-vendor) HOT 1
- Laravel 6 compatibility HOT 4
- Cyrillic symbols is not working in not saving,
- Please fix with php 7.4 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-langman.