Example #1
0
 def test_load_from_file(self):
     translations = Translations(filename="default.json")
     self.assertEqual(
         translations.get_title("any/path/with/en-GB/asdf",
                                "screenshot.png"), "DEFAULT TRANSLATION")
     self.assertIsNone(
         translations.get_title("any/path/with/en-GB/asdf",
                                "onlymessage.png"))
def process_projects(src_directory, glossary_description, glossary_file):
    corpus = Corpus(src_directory)
    corpus.process()

    reference_sources = ReferenceSources()
    reference_sources.read_sources()

    metrics = Metrics()
    metrics.create(corpus)

    # Select terms
    MAX_TERMS = 5000
    sorted_terms_by_tfxdf = sorted(metrics.tfxdf, key=metrics.tfxdf.get,
                                   reverse=True)

    # Developer report
    glossary_entries = OrderedDict()
    translations = Translations()
    selected_terms = sorted_terms_by_tfxdf[:MAX_TERMS] # Sorted by frequency

    for term in selected_terms:
        glossary_entries[term] = translations.create_for_word_sorted_by_frequency(corpus.documents, term, reference_sources)

    dev_glossary_serializer = DevGlossarySerializer()
    dev_glossary_serializer.create(u"dev-" + glossary_file + ".html",
                                   glossary_description, corpus,
                                   glossary_entries, reference_sources)

    # User report
    glossary_entries = []
    selected_terms = sorted(sorted_terms_by_tfxdf[:MAX_TERMS])  # Sorted by term

    glossary = Glossary(glossary_description)
    for term in selected_terms:
        glossary_entry = GlossaryEntry(
            term,
            translations.create_for_word_sorted_by_frequency(corpus.documents,
                                                             term,
                                                             reference_sources)
        )
        glossary.entries.append(glossary_entry)

    glossary_entries = glossary.get_dict()
    process_template('templates/userglossary-html.mustache',
                     glossary_file + ".html", glossary_entries)
    process_template('templates/userglossary-csv.mustache',
                     glossary_file + ".csv", glossary_entries)

    generate_database(glossary, glossary_file)
Example #3
0
def process_projects(src_directory, glossary_description, glossary_file):
    corpus = Corpus(src_directory)
    corpus.process()

    reference_sources = ReferenceSources()
    reference_sources.read_sources()

    metrics = Metrics()
    metrics.create(corpus)

    # Select terms
    MAX_TERMS = 1000
    sorted_terms_by_tfxdf = sorted(metrics.tfxdf,
                                   key=metrics.tfxdf.get,
                                   reverse=True)

    # Developer report
    glossary_entries = OrderedDict()
    translations = Translations()
    selected_terms = sorted_terms_by_tfxdf[:MAX_TERMS]  # Sorted by frequency

    for term in selected_terms:
        glossary_entries[
            term] = translations.create_for_word_sorted_by_frequency(
                corpus.documents, term, reference_sources)

    dev_glossary_serializer = DevGlossarySerializer()
    dev_glossary_serializer.create(u"dev-" + glossary_file + ".html",
                                   glossary_description, corpus,
                                   glossary_entries, reference_sources)

    # User report
    glossary_entries = []
    selected_terms = sorted(
        sorted_terms_by_tfxdf[:MAX_TERMS])  # Sorted by term

    glossary = Glossary(glossary_description)
    for term in selected_terms:
        glossary_entry = GlossaryEntry(
            term,
            translations.create_for_word_sorted_by_frequency(
                corpus.documents, term, reference_sources))
        glossary.entries.append(glossary_entry)

    glossary_entries = glossary.get_dict()
    process_template('templates/userglossary-html.mustache',
                     glossary_file + ".html", glossary_entries)
    process_template('templates/userglossary-csv.mustache',
                     glossary_file + ".csv", glossary_entries)
Example #4
0
def main():
    parser = argparse.ArgumentParser(
        description='Frame screenshots with a device frame, background, etc...'
    )
    parser.add_argument(
        'folder',
        nargs="?",
        help='specify the base folder where all the screenshots can be found')
    parser.add_argument('--background',
                        dest="background",
                        default="default.jpg",
                        help='background image to use')
    parser.add_argument('--translations',
                        dest="translations",
                        default="default.json",
                        help='translations file to use')

    args = parser.parse_args()
    translations = Translations(args.translations)
    if args.folder:
        frame_fastlane_screenshots(args.folder,
                                   background=args.background,
                                   translations=translations)
    else:
        parser.parse_args(["-h"])
def process_projects():
    global glossary_file
    global glossary_description

    corpus = Corpus(src_directory)
    corpus.process()

    reference_sources = ReferenceSources()
    reference_sources.read_sources()

    metrics = Metrics()
    metrics.create(corpus)

    # Select terms
    MAX_TERMS = 1000
    sorted_terms_by_tfxdf = sorted(metrics.tfxdf, key=metrics.tfxdf.get,
                                   reverse=True)

    # Developer report
    glossary_entries = OrderedDict()
    translations = Translations()
    selected_terms = sorted_terms_by_tfxdf[:MAX_TERMS] # Sorted by frequency

    for term in selected_terms:
        glossary_entries[term] = translations.create_for_word_sorted_by_frequency(corpus.documents, term, reference_sources)

    dev_glossary_serializer = DevGlossarySerializer()
    dev_glossary_serializer.create(u"dev-" + glossary_file + ".html",
                                   glossary_description, corpus,
                                   glossary_entries, reference_sources)

    # User report
    glossary_entries = []
    selected_terms = sorted(sorted_terms_by_tfxdf[:MAX_TERMS])  # Sorted by term

    glossary = Glossary()
    glossary.description = glossary_description
    for term in selected_terms:
        glossary_entry = GlossaryEntry()
        glossary_entry.source_term = term
        glossary_entry.translations = translations.create_for_word_sorted_by_frequency(corpus.documents, term, reference_sources)
        glossary.entries.append(glossary_entry)

    user_glossary_serializer = UserGlossarySerializer()
    user_glossary_serializer.create(glossary_file, glossary.get_dict(),
                                    reference_sources)
Example #6
0
def main():
    settings = getSettings()
    print(settings)

    print("Authorizing application with Google auth...")
    service = authorize()
    if service is None:
        print("Failed to authorize application. Please try again.")
        return
    else:
        print("Authorized application.")

    translations = Translations(service, settings)
    generator = Generator(translations, settings)

    print()
    print()

    generator.generate()
Example #7
0
 def test_translations(self):
     translations = Translations() \
         .add("screen1", "de-DE", "Titel", "Text") \
         .add("screen1", "en-GB", "Title", "Message")
     self.assertEqual(
         translations.get_title("any/path/with/de-DE/asdf", "screen1.png"),
         "Titel")
     self.assertEqual(
         translations.get_title("any/path/with/en-GB/asdf", "screen1.png"),
         "Title")
     self.assertEqual(
         translations.get_message("any/path/with/de-DE/asdf",
                                  "screen1.png"), "Text")
     self.assertEqual(
         translations.get_message("any/path/with/en-GB/asdf",
                                  "screen1.png"), "Message")
Example #8
0
def get_possible_translations(id):
    return Translations(get_language(id)).bible_translations
Example #9
0
def get_default_bible_translation(id):
    return Translations(get_language(id)).default_translation
Example #10
0
def get_language_config_by_id(id):
    return Translations(get_language(id))
Example #11
0
def get_language_config(language):
    return Translations(language)