def maybe_add_localization()

in fluent/migrate/_context.py [0:0]


    def maybe_add_localization(self, path: str):
        """Add a localization resource to migrate translations from.

        Uses a compare-locales parser to create a dict of (key, string value)
        tuples.
        For Fluent sources, we store the AST.
        """
        try:
            fullpath = os.path.join(self.localization_dir, path)
            if not fullpath.endswith(".ftl"):
                collection = self.read_legacy_resource(fullpath)
            else:
                collection = self.read_ftl_resource(fullpath)
        except OSError:
            logger = logging.getLogger("migrate")
            logger.warning(f"Missing localization file: {path}")
        else:
            self.localization_resources[path] = collection