Skip to content

Releases: EkberHasanov/translategram

v0.4.0 2023-10-22

21 Oct 20:48
5bbd6d7
Compare
Choose a tag to compare

Finally dynamic_handler_translator method added. It is not done yet, but cannot wait to publish it. There will be rework on this, to make it more functional, but don't have time to make all of these, so perhaps instead improving code, I will try to make the "marketing" of this project, maybe find eager people

v0.3.0 2023-06-17

16 Jun 20:16
Compare
Choose a tag to compare

Release 0.3.0 - Folder Name Update

This release introduces a change in the root folder name from "auto_translategram" to translategram. This update aligns the folder name with the library name for better consistency and clarity. The functionality of the library remains unaffected by this change.

Changes in this release:

  • Updated root folder name to translategram

Please refer to the release notes and updated documentation for more information. As always, feel free to provide feedback and report any issues you encounter.

v0.2.0 2023-06-12

12 Jun 15:53
Compare
Choose a tag to compare

What's Changed

  • Introducing a powerful caching system for improved performance and enhanced user experience.
  • Added a new module cache.py that provides flexible caching functionality.
  • Implemented the Cache protocol, defining the methods for storing and retrieving cached data.
from typing import Protocol, TypeVar, Union

T = TypeVar('T')


class Cache(Protocol):

 async def store(self, key: str, value: str) -> None:
     ...

 async def retrieve(self, key: str) -> Union[str, None]:
     ...
  • Implemented the PickleCache class, a concrete implementation of the cache using the pickle serialization protocol.
import pickle
from typing import Protocol, TypeVar, Union

T = TypeVar('T')

class PickleCache:
 def __init__(self, obj: T, filename: str = "translation.data") -> None:
     self._obj = obj
     self.pickle_file = filename
     with open(self.pickle_file, 'ab') as file:
         pickle.dump(self._obj, file)

 async def store(self, key: str, value: str) -> None:
     setattr(self._obj, key, value)
     with open(self.pickle_file, 'wb') as file:
         pickle.dump(self._obj, file)

 async def retrieve(self, key: str) -> Union[str, None]:
     with open(self.pickle_file, 'rb') as file:
         loaded_data = pickle.load(file)
     return loaded_data.__dict__.get(key) if isinstance(loaded_data.__dict__.get(key), str) else None
  • The PickleCache class enables storing and retrieving cached data using a pickle file for persistence.
  • Updated the translator.py module to support the new caching system.
  • Added a cache_system parameter to the Translator class constructor, allowing the specification of a cache system.
    def __init__(self, translator_service: TranslatorService, cache_system: Union[Type[Cache], None] = None) -> None:
     """
     Initializes a new Translator instance using the specified `translator_service`.

     :param translator_service: The `BaseTranslatorService` to use for translations.
     """
     ...
  • Modified the handler_translator method in the PythonTelegramBotAdapter class to utilize the cache system for translations.
  • Improved the translation logic in the wrapper function of the PythonTelegramBotAdapter class to incorporate the cache system.
  • Added the PickleCache import statement to the init.py module for convenient access to the cache functionality.

These changes introduce a robust caching system to library, enabling efficient storage and retrieval of translated data. The PickleCache implementation provides persistence and ensures that translations are readily available, reducing translation time and improving overall performance.

v0.1.2 2023-06-04

04 Jun 16:05
Compare
Choose a tag to compare

What's Changed

This release includes an important refactor of the handler_translator method, which has been transformed into a decorator function. This change simplifies the translation functionality and enhances the code structure.

v0.1.1

23 May 00:43
Compare
Choose a tag to compare

Release Highlights:

  • Fixed mypy errors and applied necessary updates.
  • Improved type annotations and ensured compatibility with Python 3.10.
  • Resolved compatibility issues with the python-telegram-bot framework.
  • Enhanced translation functionality for better user experience.
  • Refactored code for improved readability and maintainability.