def find_lang_postfix(project, filename):
 name = os.path.splitext(os.path.basename(filename))[0]
 if LANGCODE_RE.match(name):
  return project.lang_mapper.get_pootle_code(name)
 match = LANGCODE_POSTFIX_RE.match(name)
 if match:
  return project.lang_mapper.get_pootle_code(match.groups()[0])
 for code in Language.objects.values_list('code', flat=True):
  code = project.lang_mapper.get_upstream_code(code)
  if (name.endswith(('-' + code)) or name.endswith(('_' + code)) or name.endswith(('.' + code)) or name.lower().endswith(('-' + code.lower())) or name.endswith(('_' + code)) or name.endswith(('.' + code))):
   return code

def find_lang_postfix ( project , filename ) : name = os . path . splitext ( os . path . basename ( filename ) ) [ 0 ] if LANGCODE_RE . match ( name ) : return project . lang_mapper . get_pootle_code ( name ) match = LANGCODE_POSTFIX_RE . match ( name ) if match : return project . lang_mapper . get_pootle_code ( match . groups ( ) [ 0 ] ) for code in Language . objects . values_list ( 'code' , flat = True ) : code = project . lang_mapper . get_upstream_code ( code ) if ( name . endswith ( ( '-' + code ) ) or name . endswith ( ( '_' + code ) ) or name . endswith ( ( '.' + code ) ) or name . lower ( ) . endswith ( ( '-' + code . lower ( ) ) ) or name . endswith ( ( '_' + code ) ) or name . endswith ( ( '.' + code ) ) ) : return code
finds the language code at end of a filename .