-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does not actually remove keys #202
Comments
Works for me. Would be nice if you could give the link to the existing source(best if it would be codesandbox or similar) |
You can try with this repo https://github.com/WeakAuras/WeakAuras-Companion |
The vue-i18n-extract is missing in this repository... |
Sadly not, they don't get removed which is what I'm reporting here. |
As I said, they are - problem on your side. |
Can you show a screenshot of the diff? Because it does not here, only changes the new-line at the end of the file |
I already deleted the repo. But here what I did:
|
Problem there is that it should not even be needed to add a new key, there are unused keys in there that should be removed when you run the command, but they don't |
The plugin told me that there were found 4xx(I thing it was 415, but not sure now) unused keys, I didn't paid attention to them, since I'm not familiar with the project. |
The comment probably is the issue here. Try to remove it and use just |
no luck |
I have the same issue on my internal codebase. Will try to debug. |
So here's the issue on my side: my language files are simple key-value pairs in dot notation (hereafter "flat file"):
vue-extract-i18n expects language files to be hierarchical instead (hereafter "hierarchical file"):
Internally, The report creation accidentally works on "flat" language files because Vue-i18n-extract's code does not check the return value from |
One fix would be to update the export function removeUnusedFromLanguageFiles (parsedLanguageFiles: SimpleFile[], unusedKeys: I18NItem[], dot: DotObject.Dot = Dot): void {
parsedLanguageFiles.forEach(languageFile => {
const languageFileContent = JSON.parse(languageFile.content);
unusedKeys.forEach(item => {
if (item.language && languageFile.fileName.includes(item.language)) {
if (languageFileContent.hasOwnProperty(item.path)) {
delete languageFileContent[item.path]
} else if (dot.delete(item.path, languageFileContent) === undefined) {
console.warn("Failed to remove key", item.path, "from", languageFile.fileName)
}
}
});
writeLanguageFile(languageFile, languageFileContent);
});
} However this is not ideal as using the "add missing keys" feature of vue-i18n-extract will change the format of the files. Would you accept such a patch? |
Hah! another probable workaround: set the "separator" option to a random string. |
oh wow, great investigation |
'buggy' is a workaround for Spittal/vue-i18n-extract#202
When i run
npx vue-i18n-extract report --remove --vueFiles './src/components/**/*.?(js|vue)' --languageFiles './i18n/*.json'
on my codebase the report correctly identifies the unused keys and says it would delete them but doesn't actually do it.The text was updated successfully, but these errors were encountered: