"""Script to print list of all crowdin language codes for project."""

from crowdin_bot import api

NS_DICT = {
    'ns': "urn:oasis:names:tc:xliff:document:1.2"
}

def get_project_languages():
    """Get list of crowdin language codes.

    Returns:
        (list) list of project crowdin language codes
    """
    info_xml = api.api_call_xml("info")
    languages = info_xml.find('languages')
    translatable_languages = []
    for language in languages:
        # Check it's not the incontext pseudo language
        if language.find("can_translate").text == "1":
            translatable_languages.append(language.find('code').text)
    return translatable_languages

if __name__ == "__main__":
    print('\n'.join(get_project_languages()))

"""Script to print list of all crowdin language codes for project."""

from crowdin_bot import api

NS_DICT = {
    'ns': "urn:oasis:names:tc:xliff:document:1.2"
}

def get_project_languages():
    """Get list of crowdin language codes.

    Returns:
        (list) list of project crowdin language codes
    """
    active_languages = []
    trans_status = api.api_call_json("status")
    for language in trans_status:
        # Check language has actually had some translation done
        if int(language["words_approved"]) > 0:
            active_languages.append(language["code"])
    return active_languages

if __name__ == "__main__":
    for language in get_project_languages():
        print(language)

Modify crowdin_bot to only include languages that have >0 translations
Modify crowdin_bot to only include languages that have >0 translations

  """Script to print list of all crowdin language codes for project."""
  
  from crowdin_bot import api
  
  NS_DICT = {
      'ns': "urn:oasis:names:tc:xliff:document:1.2"
  }
  
  def get_project_languages():
      """Get list of crowdin language codes.
  
      Returns:
          (list) list of project crowdin language codes
      """
-     info_xml = api.api_call_xml("info")
-     languages = info_xml.find('languages')
-     translatable_languages = []
+     active_languages = []
+     trans_status = api.api_call_json("status")
-     for language in languages:
+     for language in trans_status:
-         # Check it's not the incontext pseudo language
-         if language.find("can_translate").text == "1":
-             translatable_languages.append(language.find('code').text)
+         # Check language has actually had some translation done
+         if int(language["words_approved"]) > 0:
+             active_languages.append(language["code"])
-     return translatable_languages
+     return active_languages
  
  if __name__ == "__main__":
-     print('\n'.join(get_project_languages()))
+     for language in get_project_languages():
+         print(language)
  
Modify crowdin_bot to only include languages that have >0 translations
## Code Before:
"""Script to print list of all crowdin language codes for project."""

from crowdin_bot import api

NS_DICT = {
    'ns': "urn:oasis:names:tc:xliff:document:1.2"
}

def get_project_languages():
    """Get list of crowdin language codes.

    Returns:
        (list) list of project crowdin language codes
    """
    info_xml = api.api_call_xml("info")
    languages = info_xml.find('languages')
    translatable_languages = []
    for language in languages:
        # Check it's not the incontext pseudo language
        if language.find("can_translate").text == "1":
            translatable_languages.append(language.find('code').text)
    return translatable_languages

if __name__ == "__main__":
    print('\n'.join(get_project_languages()))

## Instruction:
Modify crowdin_bot to only include languages that have >0 translations
## Code After:
"""Script to print list of all crowdin language codes for project."""

from crowdin_bot import api

NS_DICT = {
    'ns': "urn:oasis:names:tc:xliff:document:1.2"
}

def get_project_languages():
    """Get list of crowdin language codes.

    Returns:
        (list) list of project crowdin language codes
    """
    active_languages = []
    trans_status = api.api_call_json("status")
    for language in trans_status:
        # Check language has actually had some translation done
        if int(language["words_approved"]) > 0:
            active_languages.append(language["code"])
    return active_languages

if __name__ == "__main__":
    for language in get_project_languages():
        print(language)
