Skip to content

Added core to support .yaml files #41

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

Open
wants to merge 10 commits into
base: dev
Choose a base branch
from
Open

Conversation

klaymov
Copy link

@klaymov klaymov commented Apr 15, 2025

Adapter to support .yaml files

Created by: https://github.com/klaymov

Adapter to support .yaml files

Created by: https://github.com/klaymov
self._load_locales()

def _load_locales(self):
for filename in os.listdir(self.path):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Path and it's methods from pathlib instead of os


def _load_locales(self):
for filename in os.listdir(self.path):
if filename.endswith('.yaml') or filename.endswith('.yml'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Path(...).suffix

pass
return text

# full project in: https://github.com/klaymov/aiogram_i18n-yaml_core
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove it

@JrooTJunior JrooTJunior requested a review from Copilot April 19, 2025 12:24
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for .yaml files by introducing a new translation core and updating corresponding tests and dependency configurations.

  • Added a new YAML core adapter in aiogram_i18n/cores/yaml_core.py.
  • Updated tests to include a yaml_core fixture and included PyYAML as a dependency.
  • Updated module initialization in init.py to export the new YamlCore.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
tests/test_cores.py Added fixture for yaml_core to verify YAML translations support.
pyproject.toml Added PyYAML dependency under the yml dependency group.
aiogram_i18n/cores/yaml_core.py New implementation of YamlCore for loading YAML translations.
aiogram_i18n/cores/init.py Exported YamlCore to integrate with the core framework.

translations: Dict[str, Dict[str, Any]] = {}
locales = self._extract_locales(self.path)
for file_ext in (".yaml", ".yml"):
for locale, paths in self._find_locales(self.path, locales, file_ext).items():
Copy link
Preview

Copilot AI Apr 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing file_ext as a string instead of a tuple may lead to incorrect behavior in _find_locales. Consider wrapping file_ext in a tuple, e.g. (file_ext,), to match the expected parameter type.

Suggested change
for locale, paths in self._find_locales(self.path, locales, file_ext).items():
for locale, paths in self._find_locales(self.path, locales, (file_ext,)).items():

Copilot uses AI. Check for mistakes.

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.

2 participants