-
-
Notifications
You must be signed in to change notification settings - Fork 142
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
Feature/add translations #441
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
}; | ||
|
||
// [TODO] - add types | ||
export type LabelKeys = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add types
@@ -0,0 +1,43 @@ | |||
import { RecursiveDotNotation } from '../types/i18n'; | |||
|
|||
export const DEFAULT_LABEL_TEXT_MAP = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
packages/core/i18n/README.md
Outdated
@@ -0,0 +1,126 @@ | |||
# Exports |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -0,0 +1 @@ | |||
export {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of removed, added the Provider
editor.setLanguage = (lang: string) => { | ||
if (translations[lang]) { | ||
editor.language = lang; | ||
// editor.emit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add event emit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -25,6 +25,7 @@ import withShadcnUILibrary from '@/components/examples/withShadcnUILibrary'; | |||
import withEditorHistory from '@/components/examples/withEditorHistory'; | |||
import withEditorOperations from '@/components/examples/withEditorOperations'; | |||
import withEmailBuilder from '@/components/examples/withEmailBuilder'; | |||
import withTranslations from '@/components/examples/withTranslations'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update examples after publishing patch version
d939fc9
to
33ddcc3
Compare
* feat: emit language-change event on setLanguage * fix: make editor i18n agnostic * chore: improve dev example and docs * feat: create I18nYooEditorProvider and use hook in example
Description
I18n is being developed here in collaboration with @gloaysa
How it works
First of all, it should be noted that a new method
editor.getLabelText
has appeared in the editor instance.This method processes all kinds of labels that are available in Yoopta packages (in the core package, in tools, in plugins).
Here are usage examples:
Text labels for BlockOptions in the package
@yoopta/editor
- source codeIn tools - source code
In plugins - (the example will be ready later)
As we can see, when calling
editor.getLabelText
, we pass string. This string is the path to the object, which we will then pass using thewithTranslation
extension from the@yoopta/i18n
package:In
withTranslation
, we extend the capabilities ofgetLabelText
, where we take from the passed translation object for the current language the value from the path that we passed toeditor.getLabelText
earlier