Exemple #1
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))
Exemple #2
0
 def test_camelize_5(self):
     self.assertEqual('testCaseOne', utils.camelize('test_Case_One', keep_case=True))
Exemple #3
0
 def test_camelize_4(self):
     self.assertEqual('testCaseOne', utils.camelize('test_case_one'))