Developing add-ons
Eklentiler Weblate’de yerelleştirme iş akışını özelleştirmenin bir yoludur.
- class weblate.addons.base.BaseAddon(storage=None)
Weblate eklentileri için temel sınıf.
- classmethod can_install(component, user)
Eklentinin verilen bileşenle uyumlu olup olmadığını denetle.
- configure(settings)
Yapılandırmayı kaydet.
- daily(component)
Günlük tetiklenen kanca.
- classmethod get_add_form(user, component, **kwargs)
Yeni eklenti eklemek için yapılandırma formunu döndür.
- get_settings_form(user, **kwargs)
Bu eklenti için yapılandırma formunu döndür.
- post_add(translation)
Yeni çeviri eklendikten sonra tetiklenen kanca.
- post_commit(component)
Değişiklikler depoya işlendikten sonra tetiklenen kanca.
- post_push(component)
Depo yukarı akışa yollandıktan sonra tetiklenen kanca.
- post_update(component, previous_head: str, skip_push: bool)
Depo yukarı akıştan güncellendikten sonra tetiklenen kanca.
- Parametreler
previous_head (str) – Güncellemeden önce deponun HEAD’i, ilk klonlamada boş olabilir.
skip_push (bool) – Eklenti işleminin değişiklikleri yukarı akışa yollamayı atlayıp atlamayacağı. Genellikle bunu temeldeki yöntemlere
commit_and_push
veyacommit_pending
olarak iletebilirsiniz.
- pre_commit(translation, author)
Değişiklikler depoya işlenmeden önce tetiklenen kanca.
- pre_push(component)
Depo yukarı akışa yollanmadan önce tetiklenen kanca.
- pre_update(component)
Depo yukarı akıştan güncellenmeden önce tetiklenen kanca.
- save_state()
Eklenti durum bilgilerini kaydet.
- store_post_load(translation, store)
Bir dosya ayrıştırıldıktan sonra tetiklenen kanca.
Argüman olarak bir dosya biçimi sınıfının bir örneğini alır.
Bu, örneğin dosyanın nasıl kaydedileceğini ayarlamak gibi dosya biçimi sınıfı parametrelerini değiştirmek için faydalıdır.
- unit_pre_create(unit)
Yeni birim oluşturulmadan önce tetiklenen kanca.
Here is an example add-on:
#
# Copyright © 2012–2022 Michal Čihař <michal@cihar.com>
#
# This file is part of Weblate <https://weblate.org/>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
from django.utils.translation import gettext_lazy as _
from weblate.addons.base import BaseAddon
from weblate.addons.events import EVENT_PRE_COMMIT
class ExampleAddon(BaseAddon):
# Filter for compatible components, every key is
# matched against property of component
compat = {"file_format": {"po", "po-mono"}}
# List of events add-on should receive
events = (EVENT_PRE_COMMIT,)
# Add-on unique identifier
name = "weblate.example.example"
# Verbose name shown in the user interface
verbose = _("Example add-on")
# Detailed add-on description
description = _("This add-on does nothing it is just an example.")
# Callback to implement custom behavior
def pre_commit(self, translation, author):
return