Skip to content

Latest commit

 

History

History
113 lines (77 loc) · 2.88 KB

README.md

File metadata and controls

113 lines (77 loc) · 2.88 KB
Български Deutsch English Русский Українська

I18nService

Release License clasp

I18nService is an object that implements internationalization functionality.

Installation

  1. Open your project in the Google Apps Script Dashboard.
  2. Copy the contents of the i18n.js file and paste it into a new file in your Google Apps Script project.

Documentation

For detailed documentation, please visit the Wiki page.

Usage

Example 1

const data = {
  "bg": {
    title: "Тестово приложение"
  },
  "de": {
    title: "Testanwendung"
  },
  "en": {
    title: "Example Application"
  },
  "ru": {
    title: "Тестовое приложение"
  },
  "uk": {
    title: "Тестовий застосунок"
  }
};

const i18n = I18nService
  .init('ru')
  .load(data);

console.log(i18n.getLanguage('en').getTranslate('title'));
console.log(__('title'));

Example 2

const data = {
  title: "Example Application"
};
const locale = "en";

const i18n = I18nService
  .init(locale)
  .load(data, locale);

console.log(i18n.getLanguage(locale).getTranslate('title'));
console.log(__('title'));

Example 3

const sheet = SpreadsheetApp
  .getActiveSpreadsheet()
  .getSheetByName('I18n');

const i18n = I18nService
  .init('en')
  .load(sheet);

console.log(i18n.getLanguage('en').getTranslate('title'));
console.log(__('title'));

Tasks

  • Add the ability to load translations in json format via url-link to the I18n.load() method.
  • Use CacheService for language storage.

Contribution

Please read CONTRIBUTING.md for details on how to contribute to this project.

Change History

Please refer to CHANGELOG.md for a detailed list of changes and updates.

License

This project is licensed under the LICENSE.md file.