lsaudon / l10nization

L10nization is a tool for extracting text to arb files for l10n or r13n in a Flutter application.
https://marketplace.visualstudio.com/items?itemName=lsaudon.l10nization
MIT License
20 stars 6 forks source link

not working with .arb file JSON Error #255

Open DionJChapman opened 1 year ago

DionJChapman commented 1 year ago

I am getting the following errors

Expected ',' or '}' after property value in JSON at position 1080

Expected double-quoted property name in JSON at position 11066

I only have 369 lines in my .arb file.

lsaudon commented 1 year ago

Hi @DionJChapman,

Position is not line is number of characters in all document. Is your file a valid json? You can paste your file in this website https://jsonformatter.curiousconcept.com/#

DionJChapman commented 1 year ago

Hi Thanks for that, it had a duplicate key, but now I have another error. Does it work with Simplified Chinese?

Bad escaped character in JSON at position 4068

all that seems to be there is "couldn't"

Link to files https://www.dropbox.com/sh/t0khuj73i42w3id/AABt7ImyjfMtjjVZ8WJ8OrhGa?dl=0

lsaudon commented 1 year ago

Replace "@@local": "en_AU", by "@@locale": "en_AU", and you are the same value in 2 files. I think you want "@@locale": "zh_CH"

lsaudon commented 1 year ago

You are on windows or macos ? What is the encoding utf-8 or other ?

DionJChapman commented 1 year ago

Replace "@@local": "en_AU", by "@@locale": "en_AU", and you are the same value in 2 files. I think you want "@@locale": "zh_CH"

Oops, fixed that. But still the same issue.

I am currently on Mac, but I can try Windows tomorrow and report the findings.

lsaudon commented 1 year ago

Do you have trouble adding a translation?

DionJChapman commented 1 year ago

Do you have trouble adding a translation?

I have issues adding them manually and using them in the app in English and Chinese.

Just can't use the extension to select text and add with your Extension.

done some more testing, still get an error with this in the files { }

lsaudon commented 1 year ago

I don't understand when to use my extension. Doesn't the extension display the option in the menu when a text is selected?

DionJChapman commented 1 year ago

I don't understand when to use my extension. Doesn't the extension display the option in the menu when a text is selected?

I highlight the text, including the double quotes, then click the light bulb and then click Extract values to arb file. In the field I press enter to accept the name.

In Windows this works perfectly, thank you. On a Mac, it comes up with an error in the bottom right of the screen.

DionJChapman commented 1 year ago

I assume that you do not have a Mac to test with.

Since I am interested in writing some VSCode Extensions, I will have a go at debugging this and getting it working on a Mac for you.

If you find anything or have some pointers, please let me know here.

lsaudon commented 1 year ago

I'm trying on my mac with your files.

I don't have this problem.

Do you have a particular encoding?

DionJChapman commented 1 year ago

I'm trying on my mac with your files.

I don't have this problem.

Do you have a particular encoding?

Sorry, I have only had a Mac for a few months. How would I do this, and how would I check?

lsaudon commented 1 year ago

You can try with a empty arb file juste with @@locale in valid json.

{ "@@locale": "en" }

DionJChapman commented 1 year ago

You can try with a empty arb file juste with @@Locale in valid json.

{ "@@Locale": "en" }

I tried that and others.

I should get some time on the weekend to download the code, package it up and debug any error messages it displays.

DionJChapman commented 1 year ago

I have worked out what it is. It should be fixed to work correctly. but I can work with how it is now

in l10n.yaml I had arb-dir: lib/l10n and my files were in lib/l10n

but your extension requires arb-dir: lib/l10n/arb and the need to be in lib/l10n/arb

this documentation only specifies lib/l10n https://docs.flutter.dev/accessibility-and-localization/internationalization

lsaudon commented 1 year ago

Hi @DionJChapman,

With this modification, you no longer have the problem?

Strange, because normally it retrieves the path from the 'l10n.yaml' file for the arb folder.

What's more, the error you're getting seems to be about JSON and not about finding the 'arb' files.

lsaudon commented 1 year ago

I try with this l10n.yaml

arb-dir: lib/l10n
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart
nullable-getter: false

It's work