Skip to content

fix bug value.replace is not a function - #3

Open
HelAsia wants to merge 1 commit into
NeverwinterMoon:masterfrom
HelAsia:master
Open

fix bug value.replace is not a function#3
HelAsia wants to merge 1 commit into
NeverwinterMoon:masterfrom
HelAsia:master

Conversation

@HelAsia

@HelAsia HelAsia commented Aug 20, 2021

Copy link
Copy Markdown

fixed bug after last library update. Bug was "value.replace is not a function" during launch script.

@NeverwinterMoon

NeverwinterMoon commented Aug 24, 2021

Copy link
Copy Markdown
Owner

@HelAsia

Interesting, I am using iOS transformation exclusively in my current project and I don't have this error.

For instance, here is an output of console.log(value, typeof value):
Nächste string

We are using huge translation sheets and it works for all of them, the value is always a string... Could you somehow show me what sort of situation would fail?

@HelAsia

HelAsia commented Aug 25, 2021

Copy link
Copy Markdown
Author

I have this issue in my iOS and Android projects. Implementation is like You described in ReadMe and I have error like this:

(node:1692) UnhandledPromiseRejectionWarning: TypeError: value.replace is not a function
at Object.transformKeyValue (/Users/asiaheluszka/projects/myspiroo-android/node_modules/localize-with-spreadsheet-2/core/Transformer.js:35:33)
at FileWriter.getTransformedLines (/Users/asiaheluszka/projects/myspiroo-android/node_modules/localize-with-spreadsheet-2/core/Writer.js:54:38)
at FileWriter.write (/Users/asiaheluszka/projects/myspiroo-android/node_modules/localize-with-spreadsheet-2/core/Writer.js:13:30)
at Gs2File.save (/Users/asiaheluszka/projects/myspiroo-android/node_modules/localize-with-spreadsheet-2/index.js:69:18)
at processTicksAndRejections (internal/process/task_queues.js:97:5)

My script:
var Localize = require("localize-with-spreadsheet-2");
Localize.fromGoogleSpreadsheet('[api-key]', '[spreadsheet-key]', '*')
.then(localizer => {
localizer.setKeyCol('name')

localizer.save("../app/src/main/res/values/strings.xml", { valueCol: 'English', format: 'android' });
localizer.save("../app/src/main/res/values-pl/strings.xml", { valueCol: 'Polish', format: 'android' });
localizer.save("../app/src/main/res/values-de/strings.xml", { valueCol: 'German', format: 'android' });
})

@NeverwinterMoon

Copy link
Copy Markdown
Owner

@HelAsia thanks for the response. The usage use absolutely correct, I was just curious about the value received for the key in the transformer, so something along the lines of

    try {
      value.replace(/%newline%/gi, "\\n");
    } catch (_) {
      console.log(value, typeof value)
    }

But I think I might have an idea about your case. You probably have a number as a localization value there.

To be honest, I don't understand why a pure number value (and if you have text with a number, it's already going to work) should be as part of a localization.

Basically, this sort of translation would break:

image

This wouldn't (here it's still a number but formatter as "plain text"):
image

Above, I just set number formatting to "plain text" and this already wouldn't break this utility without any code change:

image

Once again, why would numbers be a part of localization and not code?

I would like to know the use-case out of curiosity.

@Lukaszz112

Copy link
Copy Markdown

can u merge it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants