def _determine_language_pair()

in remote_settings/client.py [0:0]


    def _determine_language_pair(name):
        """Determines the language pair based on the name of the file.

        Args:
            name str: The name of a file to attach to a record

        Returns:
            Tuple[str, str]: The (fromLang, toLang) pair for this file
        """
        segments = name.split(".")

        # File names are of the following formats:
        #   - model.{lang_pair}.intgemm8.bin.gz
        #   - lex.{lang_pair}.s2t.bin.gz
        #   - lex.50.50.{lang_pair}.s2t.bin.gz
        #   - trgvocab.{lang_pair}.spm.gz
        #   - srcvocab.{lang_pair}.spm.gz
        #   - qualityModel.{lang_pair}.bin.gz
        #   - vocab.{lang_pair}.spm.gz
        #
        # The lang_pair will always be in the one-index, except for
        # the lex.50.50... file, in which case it is in the three-index segment.
        lang_pair_segment = segments[1]
        if len(lang_pair_segment) < 4:
            lang_pair_segment = segments[3]
        return (lang_pair_segment[:2], lang_pair_segment[-2:])