Skip to content
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

not working with .arb file JSON Error #255

Open
DionJChapman opened this issue Jul 12, 2023 · 17 comments
Open

not working with .arb file JSON Error #255

DionJChapman opened this issue Jul 12, 2023 · 17 comments
Labels
bug Something isn't working

Comments

@DionJChapman
Copy link

DionJChapman commented Jul 12, 2023

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
Copy link
Owner

lsaudon commented Jul 12, 2023

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
Copy link
Author

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
Copy link
Owner

lsaudon commented Jul 12, 2023

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
Copy link
Owner

lsaudon commented Jul 12, 2023

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

@DionJChapman
Copy link
Author

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
Copy link
Owner

lsaudon commented Jul 12, 2023

Do you have trouble adding a translation?

@DionJChapman
Copy link
Author

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
Copy link
Owner

lsaudon commented Jul 12, 2023

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
Copy link
Author

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
Copy link
Author

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
Copy link
Owner

lsaudon commented Jul 13, 2023

I'm trying on my mac with your files.

I don't have this problem.

Do you have a particular encoding?

@DionJChapman
Copy link
Author

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
Copy link
Owner

lsaudon commented Jul 14, 2023

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

{
"@@Locale": "en"
}

@DionJChapman
Copy link
Author

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
Copy link
Author

DionJChapman commented Jul 15, 2023

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
Copy link
Owner

lsaudon commented Jul 17, 2023

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
Copy link
Owner

lsaudon commented Jul 26, 2023

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 lsaudon added the bug Something isn't working label Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants