Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
emoji.EMOJI_DATA
withemoji.config.load_language("zh")
All the data from EMOJI_DATA is moved into JSON files:
The metadata and the English names and aliases are in emoji.json
The other languages have individual files e.g. emoji_fr.json
The literal EMOJI_DATA in Python is removed. I left a small part of it in place for documentation, but it is not used.
By default only emoji.json is loaded into EMOJI_DATA, so only English and aliases.
If you call
emoji.emojize()
oremoji.demojize()
with a language parameter, then the language is loaded automatically.Only if you access the EMOJI_DATA directly, you need to load the language first.
For this there is a new function
emoji.config.load_language('fr')
.However to avoid this being a breaking change, I have added the magic
__missing__(key)
method to the EMOJI_DATA dictionary: https://github.com/cvzi/emoji/blob/json_emoji/emoji/unicode_codes/__init__.py#L59-L72This will automatically load the language, e.g. if you access
EMOJI_DATA['❤️']['fr']
it will automatically load French. It will only show a deprecation warning, that you should use emoji.config.load_language.In the next version this can be removed and then
EMOJI_DATA['❤️']['fr']
will raise an Exception if French was not loaded beforehand.I formatted the code with the
ruff
tool, that's why all files have changes, so you better look at the individual commits if you want to check what I have changed.