Open tmerten opened 5 years ago
And already an update ;). If I run it with increased heap size I get:
NODE_OPTIONS=--max_old_space_size=4096 ./node_modules/.bin/vue-translation-manager translate src/views/overview/
/Users/thorsten/src/development/frontend/node_modules/vue-translation-manager/node_modules/yargs/yargs.js:1148
else throw err
^
RangeError: Invalid string length
at extractTemplateExpression (/Users/thorsten/src/development/frontend/node_modules/vue-translation-manager/index.js:90:52)
at checkTemplateExpression (/Users/thorsten/src/development/frontend/node_modules/vue-translation-manager/index.js:101:20)
at matches.map (/Users/thorsten/src/development/frontend/node_modules/vue-translation-manager/index.js:121:27)
at Array.map (<anonymous>)
at TranslationManager.getStringsForComponent (/Users/thorsten/src/development/frontend/node_modules/vue-translation-manager/index.js:120:33)
at containsUntranslatedStrings (/Users/thorsten/src/development/frontend/node_modules/vue-translation-manager/bin.js:268:25)
at files.filter (/Users/thorsten/src/development/frontend/node_modules/vue-translation-manager/bin.js:157:55)
at Array.filter (<anonymous>)
at launchInteractiveTranslationPrompt (/Users/thorsten/src/development/frontend/node_modules/vue-translation-manager/bin.js:157:38)
at Object.require.command [as handler] (/Users/thorsten/src/development/frontend/node_modules/vue-translation-manager/bin.js:20:5)
which might be due to our too long translation keys at some places (?).
Hey @tmerten, sorry for only responding now.
Could you try to prepare a small example that reproduces this problem? And how long are your translation keys anyway?
Hi @MaxGfeller . Nevermind.
Unfortunately it is hard to make it reproducible in a small example. We have some dusty places where the translation keys are the English sentence (as VueI18N uses the key as default). I found keys of 100
+ chars (including whitespaces) if that helps (however, we are working on getting rid of those as it is clearly not even close to a best practice ;) ).
Anyways, if I find some time, I can check if I can reproduce it in an empty project using some long lorem ipsum
keys.
Hey, i was able to replicate this. I did some debugging and i think sometimes it gets confused and then starts matching where the closing index is lower than the opening index. When this happens the text
string starts to grow until it runs out of memory
I fixed it by hacking the code in place to check if the close index is less than open index
@freakypie : That is great news, thanks for digging. And, hey, I am sorry for not putting more effort in from our side. Meanwhile we also did clean up the project files a lot so I'll give it another go.
I just tried to run vue translation manager on a bigger project and received a stack trace. (more info below)
As the project is private I cannot paste/refer to the code, but a quick
grep -R "\$t(" * | wc -l
results in about 1200 calls (maybe missing some in plain.js
files, but not much) with rather long keys currently (I wanted to setup vue translation manager to refactor this ;) ).However, I was wondering if it makes sense to add an option to pass a path or a single
.vue
file totranslate
. This way one would be able to translate only parts of the project (which is what I want to do most of the time).