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

Add preprocessors #9

Merged
merged 4 commits into from Jan 6, 2022
Merged

Add preprocessors #9

merged 4 commits into from Jan 6, 2022

Conversation

zumkorn
Copy link
Contributor

@zumkorn zumkorn commented Jan 5, 2022

Issue #1
I added the createPreprocessor function to create a preprocessor.
The developer can specify any store to listen for changes and re-render translations.

import { createPreprocessor } from '@nanostores/i18n'
const screenSize = atom('big')
const sizePreprocessor = createPreprocessor(screenSize)

Add preprocessor:

export const i18n = createI18n(locale, {
  get: ,
  preprocessors: [
    sizePreprocessor
  ]
})

Create messages:

export const messages = i18n({
  send: sizePreprocessor.process({
    big: 'Send message',
    small: 'send'
  }),
  name: 'User name'
})

Return translate:

export const SendLabel = () => {
  const t = useStore(messages)
  return t.send()
}

@ai
Copy link
Member

ai commented Jan 5, 2022

Can you update size limit in package.json and add TSDoc to createPreprocessor?

@zumkorn
Copy link
Contributor Author

zumkorn commented Jan 6, 2022

Can you update size limit in package.json and add TSDoc to createPreprocessor?

Added

README.md Show resolved Hide resolved
@ai
Copy link
Member

ai commented Jan 6, 2022

Size Limit is still invalid. You can run pnpm test to run all tests.

@zumkorn
Copy link
Contributor Author

zumkorn commented Jan 6, 2022

Size Limit is still invalid. You can run pnpm test to run all tests.

Fixed. Sorry, my mistake.

@ai ai merged commit dc8edc5 into nanostores:main Jan 6, 2022
@ai
Copy link
Member

ai commented Jan 6, 2022

Looks good. Thanks.

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.

None yet

2 participants