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

feat: nested object scopes #64

Merged
merged 4 commits into from
Jul 14, 2023
Merged

feat: nested object scopes #64

merged 4 commits into from
Jul 14, 2023

Conversation

QuiiBz
Copy link
Owner

@QuiiBz QuiiBz commented Jul 14, 2023

Closes #19

The current syntax for writing locale is:

export default {
  hello: 'Hello',
  welcome: 'Hello {name}!',
  'about.you': 'Hello {name}! You have {age} yo',
  'scope.test': 'A scope',
  'scope.more.test': 'A scope',
  'scope.more.param': 'A scope with {param}',
  'scope.more.and.more.test': 'A scope',
  'missing.translation.in.fr': 'This should work',
} as const

And you're now able to write locales using nested objects:

export default {
  hello: 'Hello',
  welcome: 'Hello {name}!',
  about: {
    you: 'Hello {name}! You have {age} yo',
  },
  scope: {
    test: 'A scope',
    more: {
      test: 'A scope',
      param: 'A scope with {param}',
      and: {
        more: {
          test: 'A scope',
        },
      },
    },
  },
  missing: {
    translation: {
      in: {
        fr: 'This should work',
      },
    },
  },
} as const

@QuiiBz QuiiBz mentioned this pull request Jul 14, 2023
@QuiiBz QuiiBz marked this pull request as ready for review July 14, 2023 15:01
@QuiiBz QuiiBz merged commit acb94ce into main Jul 14, 2023
3 checks passed
@QuiiBz QuiiBz deleted the feat/nested-object-scopes branch July 14, 2023 15:05
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.

Nested object scopes
1 participant