Prepare translation for add-on

Developer
Fra Poland
Member since okt. 2014

Is there a way to prepare translation to add-on that is automatically added to database after files upload to ftp (bypassing csv import)?

tim
Founder
Fra Sweden
Member since maj 2013
tim

Not really, no :( I recommend a CSV.

LiteCart Fan
Fra Poland
Member since aug. 2018

This is not exactly what you asked but I'm doing something like that in my add-on


  {
    language::translate(__CLASS__ . ':not_selected', 'You need to select a destination locker');
    $this->set_translation('pl', __CLASS__ . ":not_selected", 'Musisz wybrać docelowy paczkomat');
  }

  public function uninstall()
  {
    database::query(
      "delete from " . DB_TABLE_TRANSLATIONS . "
    where code like '%" . __CLASS__ . "%';"
    );
  }

  public function set_translation($language_code, $key, $text)
  {
    $check_column_query = database::query("SHOW COLUMNS FROM " . DB_TABLE_TRANSLATIONS . " where field = 'text_" . $language_code . "'");
    $check_column = database::fetch($check_column_query);
    if ($check_column) {
      database::query(
        "update " . DB_TABLE_TRANSLATIONS . "
          set `text_" . $language_code . "` = '" . $text . "',
          date_updated = '" . date('Y-m-d H:i:s') . "'
          where code = '" . $key . "';"
      );
    }
  }```
tim
Founder
Fra Sweden
Member since maj 2013
tim

language::translate(CLASS.':yada_yada', '...') is something that is recognized by the translation scanner. Admin -> Translations -> Scan.

Why not instruct your client to scan the platform for new translations?

This thread has been closed due to long inactivity. Posting to it is not possible.
This website uses no cookies and no third party tracking technology. We think we can do better than others and really think about your privacy.