File: strings_extractor_gettext.py

package info (click to toggle)
kf6-ktexttemplate 6.20.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,276 kB
  • sloc: cpp: 19,546; javascript: 6,043; python: 297; ruby: 24; makefile: 5
file content (27 lines) | stat: -rwxr-xr-x 1,053 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#! /usr/bin/env python
# -*- coding: utf-8 -*-

##
# SPDX-FileCopyrightText: 2010 Stephen Kelly <steveire@gmail.com>
#
# SPDX-License-Identifier: BSD-2-Clause
##

from strings_extractor import TranslationOutputter

class GettextExtractStrings(TranslationOutputter):
  def createOutput(self, template_filename, context_strings, outputfile):
    for context_string in context_strings:
      outputfile.write("// i18n: file: " + template_filename + "\n")
      if context_string.context:
        if not context_string.plural:
          outputfile.write("pgettext(\"" + context_string.context + "\", \"" + context_string._string + "\");\n")
        else:
          outputfile.write("npgettext(\"" + context_string.context + "\", \"" + context_string._string + "\", \"" + context_string.plural + "\");\n")
      else:
        if context_string.plural:
          outputfile.write("ngettext(\"" + context_string._string + "\", \"" + context_string.plural + "\");\n")
        else:
          outputfile.write("gettext(\"" + context_string._string + "\");\n")