def save(self, locale):
        """
        Load the source resource, modify it with changes made to this
        Resource instance, and save it over the locale-specific
        resource.
        """
        if self.source_resource is None:
            raise SyncError('Cannot save silme resource {0}: No source resource given.'
                            .format(self.path))

        # Only uncomment MOZ_LANGPACK_CONTRIBUTORS if we have a
        # translation for it
        new_structure = self.parser.get_structure(read_file(
            self.source_resource.path,
            uncomment_moz_langpack=self.entities.get('MOZ_LANGPACK_CONTRIBUTORS', False)
        ))

        # Update translations in the copied resource.
        entities = [
            SilmeEntity(obj) for obj in new_structure if isinstance(obj, silme.core.entity.Entity)
        ]
        for silme_entity in entities:
            key = silme_entity.key

            translated_entity = self.entities.get(key)
            if translated_entity and None in translated_entity.strings:
                translation = translated_entity.strings[None]

                if self.escape_quotes_on:
                    translation = self.escape_quotes(translation)

                new_structure.modify_entity(key, translation)
            else:
                # Remove untranslated entity and following newline
                pos = new_structure.entity_pos(key)
                new_structure.remove_entity(key)

                try:
                    line = new_structure[pos]
                except IndexError:
                    # No newline at end of file
                    continue

                if type(line) == unicode and line.startswith('\n'):
                    line = line[len('\n'):]
                    new_structure[pos] = line
                    if len(line) is 0:
                        new_structure.remove_element(pos)

        # Temporary fix for bug 1236281 until bug 721211 lands
        if self.path.endswith('browser/chrome/browser/browser.properties') and locale.code == 'zh-CN':
            new_entity = silme.core.entity.Entity(
                'browser.startup.homepage',
                'http://start.firefoxchina.cn'
            )
            new_structure.add_entity(new_entity)
            new_structure.add_string('\n')

        # Create parent directory if it doesn't exist.
        try:
            os.makedirs(os.path.dirname(self.path))
        except OSError:
            pass  # Already exists, phew!

        with codecs.open(self.path, 'w', 'utf-8') as f:
            f.write(self.parser.dump_structure(new_structure))
dataset/ETHPy150Open mozilla/pontoon/pontoon/sync/formats/silme.py/SilmeResource.save/original