l10nization icon indicating copy to clipboard operation
l10nization copied to clipboard

not working with .arb file JSON Error

Open DionJChapman opened this issue 2 years ago • 17 comments

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.

DionJChapman avatar Jul 12 '23 11:07 DionJChapman

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/#

lsaudon avatar Jul 12 '23 12:07 lsaudon

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

DionJChapman avatar Jul 12 '23 12:07 DionJChapman

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 avatar Jul 12 '23 13:07 lsaudon

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

lsaudon avatar Jul 12 '23 13:07 lsaudon

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.

DionJChapman avatar Jul 12 '23 13:07 DionJChapman

Do you have trouble adding a translation?

lsaudon avatar Jul 12 '23 14:07 lsaudon

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 { }

DionJChapman avatar Jul 12 '23 14:07 DionJChapman

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

lsaudon avatar Jul 12 '23 16:07 lsaudon

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 avatar Jul 12 '23 22:07 DionJChapman

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.

DionJChapman avatar Jul 12 '23 23:07 DionJChapman

I'm trying on my mac with your files.

I don't have this problem.

Do you have a particular encoding?

lsaudon avatar Jul 13 '23 06:07 lsaudon

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?

DionJChapman avatar Jul 14 '23 10:07 DionJChapman

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

{ "@@locale": "en" }

lsaudon avatar Jul 14 '23 14:07 lsaudon

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

{ "@@Locale": "en" }

I tried that and others.

  • It doesn't like single quotes in JSON
  • It doesn't care about single or double quotes in code
  • deleting the Chinese file didn't make a difference.
  • It is coming up with random positions

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

DionJChapman avatar Jul 14 '23 14:07 DionJChapman

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

DionJChapman avatar Jul 15 '23 10:07 DionJChapman

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 avatar Jul 17 '23 14:07 lsaudon

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

lsaudon avatar Jul 26 '23 15:07 lsaudon