Discord-localization

Latest version: v1.1.2

Safety actively analyzes 681812 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

1.1.2

* fixed various bugs
* `localizations` now doesn't accept relative paths for cogs to avoid bugs. any discord.py cog has to use the main file's path as relative paths
* `localizations` no longer has a setter: if you want to open a different file, use `json.loads` and `Localization.file`

1.1.1

* added support for yaml files
* renamed `relative_path` arg to `localizations`
* `localizations` now accepts dicts
* added setter for `localizations`
* this will open a new file and i don't recommend using it, but it's there if you need it
* added new operations
* `x == y`: checks if two Localization objects have the same `.file`
* `x != y`: checks if two Localization objects have different `.file`'s
* `dict(x)`: returns `self.file`
* added a class representation for easier debugging
* `.format_string()` is now a staticmethod, meaning you don't need to actually initalize a class to use it

**Full Changelog**: https://github.com/PearooXD/discord-localization/compare/v1.1.0...v1.1.1

1.1.0

* improved docstrings - they're now numpy styled, similar to what discord.py uses
* added support for nested keys (`data["a"]["b"]` -> `"data.a.b"`)
* added new section in the readme for an example of this
* added support for nested objects with proper kwarg formatting
* i don't think this needs an example, since this is done behind the scenes to make the use of the library more seamless
* corrected type hinting for the `locale` parameter in `.one()`

**Full Changelog**: https://github.com/PearooXD/discord-localization/compare/v1.0.1...v1.1.0

1.0.1

* added custom errors
- `InvalidJSONFormat`, `LocalizationFileNotFound`, `InvalidLocale`, `LocalizationNotFound`, `WrongLocalizationFormat`
- these inherit from default error types, such as `ValueError`, `FileNotFoundError`, `KeyError` and `TypeError`
- functionality has not changed at all, this just makes every error a bit clearer.

**Full Changelog**: https://github.com/PearooXD/discord-localization/compare/v1.0.0...v1.0.1

1.0.0

This is the stable release of `discord-localization`. This changelog will detail differences from `ezi18n`, the older, deprecated version of this package.

* updated docstrings
* `lang` argument renamed to `locale`, which will be used to refer to it from now on
* `locale` argument now takes `discord.Guild`, `discord.Locale`, `discord.Interaction` and `discord.ext.commands.Context`, for easier discord integration
* `filename` renamed to `relative_path`
* removed `suffix`, you now have to specifically define the path
* added `default_locale` (`Optional[str]`) - a fallback locale if a locale in `localize` wasn't found
* added `error` (`Optional[bool] = False`) - whether to use the `logging` module to log errors or actually raise errors (usually `KeyError` and `TypeError`)
* renamed `t()` / `translate()` to `localize()`, with 4 aliases: `_`, `t`, `translate`, `localise`
* renamed internal variables
* improved errors
* added examples
* the dist folder is now in .gitignore
* updated readme

Links

Releases

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.