Open joelcuevas opened 8 years ago
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?
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?
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.
Perfect! I think I could have something by the next week for you to review.
👍 :)
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:
(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?
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.
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.
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?