← Back to team overview

widelands-dev team mailing list archive

Re: [Merge] lp:~franku/widelands-website/devs_and_locales_list into lp:widelands-website

 

Review: Approve

I can't test this, but code LGTM - just some small formatting nits.

I also found a typo that's not in the diff:

line 86: at given position and prepaire all for wl_markdown

prepaire => prepare

Diff comments:

> === modified file 'mainpage/views.py'
> --- mainpage/views.py	2015-05-19 07:12:45 +0000
> +++ mainpage/views.py	2015-07-27 19:11:30 +0000
> @@ -51,38 +50,52 @@
>      txt = ""
>      transl_files = []
>      transl_list = []
> -    path = os.path.normpath(WIDELANDS_SVN_DIR + "txts/translators/")
> +    path = os.path.normpath(WIDELANDS_SVN_DIR + "i18n/locales/")
>      try:
>          transl_files = os.listdir(path)
>          if transl_files:
>              for fname in transl_files:
> -                if fname.endswith(".json"):
> +                if fname.endswith(".json") :

We don't have a blank space before the : anywhere else.

>                      with open(path + "/" + fname,"r") as f:
> -                        json_data = json.load(f)["locale-translators"]
> -    
> -                    if json_data["translator-list"] != "translator-credits":
> +                        json_data = json.load(f)
> +                    
> +                    try:
> +                        if json_data["translator-list"] != "translator-credits":
>                              transl_list.append(json_data)
> +                    except KeyError:
> +                        transl_list = ["KeyError"]
> +                        
> +            # Check for the other key we need
> +            for d in transl_list:
> +                if not "your-language-name-in-english" in d:
> +                    transl_list = ["KeyError"]
> +            
> +            # No KeyError -> Sort the list
> +            if "KeyError" in transl_list:
> +                txt = "Some Translator key is wrong, please contact the Developers. \n"

Remove blank space before \n

> +            else:
> +                transl_list.sort( key=itemgetter("your-language-name-in-english"))

Remove blank space after (

> +
>          else:
> -            txt = "No files for translators found!"
> +            txt = "No files for translators found!\n"
>      except OSError:
> -        txt = txt + "Couldn't find translators directory!"
> +        txt = txt + "Couldn't find translators directory!\n"
>  
>                 
>      # Get other developers, put in the translators list
>      # at given position and prepaire all for wl_markdown
>      try:
> -        f = open(WIDELANDS_SVN_DIR + "txts/developers.json", "r")
> -        json_data = json.load(f)["developers"]
> -        f.close()
> -    
> +        with open(WIDELANDS_SVN_DIR + "txts/developers.json", "r") as f:
> +            json_data = json.load(f)["developers"]
> +
>          for head in json_data:
>              # Add first header
>              txt = txt + "##" + head["heading"] + "\n"
> -            # Inserting Translators
> -            if head["heading"] == "Translators":
> +            # Inserting Translators if there was no error
> +            if head["heading"] == "Translators" and "KeyError" not in transl_list:
>                  for values in (transl_list):
>                      # Add subheader for locale
> -                    txt = txt + "### " + values["your-language-name"] + "\n"
> +                    txt = txt + "### " + values["your-language-name-in-english"] + "\n"
>                      # Prepaire the names for wl_markdown

Prepaire => Prepare

>                      txt = txt + "* " + values["translator-list"].replace('\n', '\n* ') + "\n"
>                      


-- 
https://code.launchpad.net/~franku/widelands-website/devs_and_locales_list/+merge/266025
Your team Widelands Developers is subscribed to branch lp:widelands-website.


References