Esempio n. 1
0
def update_translation_changelist_for_undelete():
  """Create all the required translations if not defined"""
  from application import db
  from models.translation import Translation
  
  itemDict = {
    'changes_v2.1.0.2': {
      'en': """<ul>
          <li>Added the un-delete feature</li>
        </ul>""",
      'ru': """<ul>
          <li>Добавлена возможность отмены удаления</li>
        </ul>""",
      'uk': """<ul>
          <li>Додано можливість скасувати видалення</li>
        </ul>""",
    }
  }
  
  for name, itemDictValue in itemDict.items():
    for language, value in itemDictValue.items():
      translation = Translation.query.filter_by(name=name, language=language).first()
      if not translation:
        translation = Translation()
        translation.language = language
        translation.name = name
        translation.value = value
        translation.save()
      else:
        translation.value = value
        translation.save()
Esempio n. 2
0
def update_translation_data_add_about_page_translations():
  """Create all the required translations if not defined"""
  from application import db
  from models.translation import Translation
  
  itemDict = {
    'about service': {
      'en': 'About T<sup>3</sup>',
      'ru': 'О сервисе T<sup>3</sup>',
      'uk': 'Про сервіс T<sup>3</sup>'
    },
    'and others': {
      'en': 'and many others',
      'ru': 'и многим другим',
      'uk': 'та багатьом іншим'
    },
    'changes_v2.1.0.1': {
      'en': """<ul>
          <li></li>
          <li></li>
          <li></li>
          <li></li>
          <li></li>
          <li></li>
          <li></li>
          <li>Added the "About" page</li>
        </ul>""",
      'ru': '',
      'uk': ''
    },
    'common:changes': {
      'en': 'Changes',
      'ru': 'Изменения',
      'uk': 'Що нового'
    },
    'common:version_short': {
      'en': 'ver',
      'ru': 'ver',
      'uk': 'ver'
    },
    'thanks to': {
      'en': 'Thanks to',
      'ru': 'Отдельная благодарность',
      'uk': 'Дуже дякую'
    }
  }
  
  for name, itemDictValue in itemDict.items():
    for language, value in itemDictValue.items():
      translation = Translation.query.filter_by(name=name, language=language).first()
      if not translation:
        translation = Translation()
        translation.language = language
        translation.name = name
        translation.value = value
        translation.save()
      else:
        translation.value = value
        translation.save()
Esempio n. 3
0
def update_floats_separator():
  """Create all the required translations if not defined"""
  from application import db
  from models.translation import Translation

  itemDict = {
    'changes_v2.1.0.3': {
      'en': """<ul>
          <li>Added a preference: decimal separator for the floating-point numbers</li>
        </ul>""",
      'ru': """<ul>
          <li>Добавлена настройка: разделитель для дробной части в числах с плавающей точкой</li>
        </ul>""",
      'uk': """<ul>
          <li>Додано налаштування: роздільник для дробової частини в числах з плаваючою точкою</li>
        </ul>""",
    },
    'floats format': {
      'en': 'Decimal Separator',
      'ru': 'Разделитель в дробях',
      'uk': 'Роздільник в дробових числах'
    },
    'comma': {
      'en': 'Comma',
      'ru': 'Запятая',
      'uk': 'Кома'
    },
    'dot': {
      'en': 'Dot',
      'ru': 'Точка',
      'uk': 'Крапка'
    }
  }

  for name, itemDictValue in itemDict.items():
    for language, value in itemDictValue.items():
      translation = Translation.query.filter_by(name=name, language=language).first()
      if not translation:
        translation = Translation()
        translation.language = language
        translation.name = name
        translation.value = value
        translation.save()
      else:
        translation.value = value
        translation.save()
Esempio n. 4
0
def install_translation_data():
  """Create all the required translations if not defined"""
  from application import db
  from models.translation import Translation
  
  import csv
  csvFile = open('data/t3.csv', 'rb')
  csvData = csv.reader(csvFile, delimiter=',', quotechar='"')
  csvHeaderSkipped = False
  for item in csvData:
    if not csvHeaderSkipped:
      csvHeaderSkipped = True
      continue
    
    if not len(item):
      continue
    
    name = item[0]
    valueDict = {
      'en': (len(item)>1 and str(item[1]) or ''),
      'ru': (len(item)>2 and str(item[2]) or ''),
      'uk': (len(item)>3 and str(item[3]) or '')
    }
    
    for language, value in valueDict.items():
      
      translation = Translation.query.filter_by(language=language, name=name).first()
      if not translation:
        translation = Translation()
        translation.language = language
        translation.name = name
        translation.value = value
        translation.save()
      else:
        translation.value = value
        translation.save()
      
      print '[MIGRATION:TRANSLATION]', name, language, translation
    for line in f:

        if not line.strip():
            print('file end')
            break

        # print(line)
        surah_number, ayat_number, *line_text = line.strip().split('|')
        text = ' '.join(line_text)
        print('For File ' + edition_id + ' writing line...' + str(line_count))

        trans_id = surah_number + '-' + ayat_number

        translation = Translation()
        translation.id = edition_id + "_" + trans_id
        translation.ayah_id = trans_id
        translation.edition_id = edition_id
        translation.text = text.strip()
        translation.ayah_number = line_count
        translation.save(batch=trans_batch)

        line_count += 1
        count += 1

        if (count >= 400):
            trans_batch.commit()
            count = 0

    print('============Complete=============================')
    trans_batch.commit()
Esempio n. 6
0
surah.number = 2
surah.name = 'surah-2-name'
surah.english_name = 'surah-2-english-name'
surah.number_of_ayahs = 7
surah.revelation_type = 'Mecca'
surah.save()


# import data for translation
translation = Translation()
translation.id = 'translation-ayah-1-edition-1'
translation.ayah_id = 'ayah-1'
translation.ayah_number = 1
translation.edition_id = 'edition-1'
translation.text = 'Translation for ayah-1 edition-1'
translation.save()

translation = Translation()
translation.id = 'translation-ayah-1-edition-2'
translation.ayah_id = 'ayah-1'
translation.ayah_number = 1
translation.edition_id = 'edition-2'
translation.text = 'Translation for ayah-1 edition-2'
translation.save()

translation = Translation()
translation.id = 'translation-ayah-2-edition-1'
translation.ayah_id = 'ayah-2'
translation.ayah_number = 2
translation.edition_id = 'edition-1'
translation.text = 'Translation for ayah-2 edition-1'