Esempio n. 1
0
 def test_comment_lines_long(self):
     string = ' this is a line of regular comment which is very long and spreads across more than a single line ' \
              'so it should be split in multiple comment lines'
     self.assertEqual(['//  this is a line of regular comment which is very long and',
                       '// spreads across more than a single line so it should be split',
                       '// in multiple comment lines'],
                      utils.to_comment_lines(string))
Esempio n. 2
0
    def generate_namespace_supporting_files(
            self, arguments: NamespaceSupportingFilesArguments):
        projectNamespace = self._sanitize_namespace_name(
            arguments.namespace_name)
        outputDir = self._get_supporting_files_dir(
            arguments.project_output_dir)
        outputFile = os.path.join(
            outputDir, 'String+{}{}.swift'.format(
                arguments.project_short_identifier.capitalize(),
                projectNamespace))

        translationFunctions = [
            TranslationFunction(
                name=utils.camelize(key['key']),
                localisedKey=key['key'].strip(),
                localisedKeyValue=self._sanitize_localised_key_value(
                    key['value']),
                localisedKeyValueContainsHTML=key['contains_HTML'],
                localisedKeyComment=utils.to_comment_lines(key['comment']),
                parameters=self._get_translation_function_parameters(
                    key['value']),
                placeholders=utils.get_placeholders(key['value']))
            for key in arguments.localised_keys
        ]

        with open(outputFile, 'w') as file:
            template = arguments.environment.get_template(
                'String+Namespace.swift')
            file.write(
                template.render(
                    projectName=arguments.project_name,
                    projectShortIdentifier=arguments.project_short_identifier,
                    projectNamespace=projectNamespace,
                    translationFunctions=translationFunctions))
Esempio n. 3
0
 def test_comment_lines_short(self):
     string = ' this is a line of regular comment'
     self.assertEqual(['// {}'.format(string)], utils.to_comment_lines(string))