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

Map with Multi worded or single worded with symbols keys from List does not work #270

Open
BaccanoMob opened this issue Dec 8, 2024 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@BaccanoMob
Copy link

Using example from README.md

{
  "niceList": [
    "hello",
    "nice",
    [
      "first item in nested list",
      "second item in nested list"
    ],
    {
      "wow": "WOW!",
      "ok": "OK!"
    },
    {
      "a map entry": "access via key",
      "another entry": "access via second key"
    }
  ]
}

when dart run slang is run to generate translations I get

// **THIS WORKS AS INTENDED**
class Translations$niceList$0i4$$niceList$0i3$EnIn {
	Translations$niceList$0i4$$niceList$0i3$EnIn.internal(this._root);

	final Translations _root; // ignore: unused_field

	// Translations
	String get wow => 'WOW!';
	String get ok => 'OK!';
}

// THIS IS GENERATAED AS THE SAME AS SINGLE WORD
class Translations$niceList$0i4$$niceList$0i4$EnIn {
	Translations$niceList$0i4$$niceList$0i4$EnIn.internal(this._root);

	final Translations _root; // ignore: unused_field

	// Translations
	String get a map entry => 'access via key'; // ERROR
	String get another entry => 'access via second key'; // ERROR
}

With symbols, "ok!!": "OK!" also generates String get ok!! => 'OK!'; and causes error.

When used with (map), works well

 "a(map)":{
      "a map entry1": "access via key",
      "another entry1": "access via second key",
      "ok!!": "OK!"
    }

Manual Fix:
uncomment all errors and its classes and add map manually. (works for simple cases and needs to be done again when code is generated afterwards)

        Translations$niceList$0i3$EnIn.internal(_root),
        // Translations$niceList$0i4$EnIn.internal(_root), 
        {
          "a map entry": "access via key",
          "another entry": "access via second key"
        }

Recommend to change the README.md with working examples.

@BaccanoMob BaccanoMob added the bug Something isn't working label Dec 8, 2024
@BaccanoMob
Copy link
Author

BaccanoMob commented Dec 8, 2024

Just found that below in slang.yaml fixes it (and prolly something similar for build.yaml as well) rather than the manual fix.

maps:
  - niceList.4

The values are from // Path: niceList.4 line above the functions with errors.

@Tienisto Tienisto added documentation Improvements or additions to documentation and removed bug Something isn't working labels Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants