How to use the nikola.utils.get_translation_candidate function in Nikola

To help you get started, we’ve selected a few Nikola examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openframeworks / ofSite / plugins / tutorials / tutorials / __init__.py View on Github external
of_book_path = os.path.join(directory, "of_book.md")
            if lang != self.site.config['DEFAULT_LANG']:
                of_book_lang_path = utils.get_translation_candidate(self.site.config, of_book_path, lang)
                p = pathlib.Path(of_book_lang_path)
                if p.exists():
                    of_book_path = of_book_lang_path
            of_book = open(of_book_path).read()
            

            ### -----------------------------------
            ### 4) BOTTOM SECTION: how to improve the doc ###

            contributing_to_docs_path = os.path.join(directory, "contributing_to_docs.md")
            if lang != self.site.config['DEFAULT_LANG']:
                contributing_to_docs_lang_path = utils.get_translation_candidate(self.site.config, contributing_to_docs_path, lang)
                p = pathlib.Path(contributing_to_docs_lang_path)
                if p.exists():
                    contributing_to_docs_path = contributing_to_docs_lang_path
            contributing_to_docs = markdown.markdown(open(contributing_to_docs_path).read())


            context = {}
            context["lang"] = lang
            if lang == self.site.config['DEFAULT_LANG']: 
                context["permalink"] = '/' + folder_name + '/'
            else:
                context["permalink"] = '/' + lang + '/' + folder_name + '/'
            context["of_book"] = of_book
            context["contributing_to_docs"] = contributing_to_docs
            context["title"] = "learning"
            context['categories'] = categories
github openframeworks / ofSite / plugins / documentation / documentation / __init__.py View on Github external
module_subtitles[module] = None

        # close js for docs search and save per language
        for lang in self.kw['translations']:
            content_js[lang] += ']};'
            content_js_file = open("output" + lang_prefix(lang, self.site) + "/tipuesearch_content.js","w")
            content_js_file.write(content_js[lang])
            content_js_file.close()

        # render index file
        template_name = "documentation.mako"
        for lang in self.kw['translations']:
            #lang_suffix = self.kw['translations'][lang]
            docs_intro_path = os.path.join(docs_dir, "index.md")
            if lang != self.site.config['DEFAULT_LANG']:
                docs_intro_lang_path = utils.get_translation_candidate(self.site.config, docs_intro_path, lang)
                p = pathlib.Path(docs_intro_lang_path)
                if p.exists():
                    docs_intro_path = docs_intro_lang_path
            docs_intro = open(docs_intro_path).read()
            for key in self.site.GLOBAL_CONTEXT.keys():
                if isinstance(self.site.GLOBAL_CONTEXT[key], str):
                   docs_intro = docs_intro.replace('${' + key + '}', self.site.GLOBAL_CONTEXT[key])
            docs_intro = markdown(docs_intro, md_extensions)
            context = {}
            context["lang"] = lang
            context["title"] = "documentation"
            context["docs_intro"] = docs_intro
            context['core'] = core_index
            context['addons'] = addons_index
            context['module_subtitles'] = module_subtitles
            context["permalink"] = self.kw['translations'][lang] + '/documentation/'
github openframeworks / ofSite / plugins / tutorials / tutorials / __init__.py View on Github external
article.translations = find_translations(article)
                return article
                
            articles = list(map(collect_translations, articles))


            categories.append({'category': category, 'articles': articles});
            
        for lang in self.kw['translations']:

            ### -----------------------------------
            ### 3) BOTTOM SECTION: GUIDES FROM OF-BOOK ###

            of_book_path = os.path.join(directory, "of_book.md")
            if lang != self.site.config['DEFAULT_LANG']:
                of_book_lang_path = utils.get_translation_candidate(self.site.config, of_book_path, lang)
                p = pathlib.Path(of_book_lang_path)
                if p.exists():
                    of_book_path = of_book_lang_path
            of_book = open(of_book_path).read()
            

            ### -----------------------------------
            ### 4) BOTTOM SECTION: how to improve the doc ###

            contributing_to_docs_path = os.path.join(directory, "contributing_to_docs.md")
            if lang != self.site.config['DEFAULT_LANG']:
                contributing_to_docs_lang_path = utils.get_translation_candidate(self.site.config, contributing_to_docs_path, lang)
                p = pathlib.Path(contributing_to_docs_lang_path)
                if p.exists():
                    contributing_to_docs_path = contributing_to_docs_lang_path
            contributing_to_docs = markdown.markdown(open(contributing_to_docs_path).read())