Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support languages="all" parameter in localize function #136

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

gilsousampbx
Copy link

@gilsousampbx gilsousampbx commented Sep 25, 2024

This PR handles languages=all param for localize function.

Summary of changes:

  • Handle languages=all: returns original language name and all languages that:
    • are different than original language name
    • have hidden_prefix omitted from the property name
  • Rename keep_every_language to keep_all_non_hidden_languages for clarity

Expected Result:

name -> raw.name
name_local -> raw.name
name_xx -> (raw.name_xx || raw.{hidden_prefix}_name_xx) && (name_xx != name)

Logic flow:

For each layer:
  For each feature:

    * For each property:
        If language property:
          If param languages=[all]:
            If property name = 'name':
              - Add {name} to {final_properties}  
            Else:
              - Remove hidden_prefix (if needed) from property name
              - Set value for {name_xx} key in {language_properties_to_be_added_to_final_properties}
          Else:
            Process with current logic - no change
    --- End of property loop ---
   
    Add {name_local} = {name} to {final_properties}
   
    * For each {name_xx} key in {language_properties_to_be_added_to_final_properties}:
        If {name_xx} value != {name} value:
          - Add {name_xx} to {final_properties}
    
  --- End of feature loop ---
--- End of layer loop ---
     

@kienbd
Copy link

kienbd commented Sep 26, 2024

✅ Unit tests

$ make test 
image

@kienbd kienbd marked this pull request as draft September 26, 2024 13:17
@kienbd
Copy link

kienbd commented Sep 26, 2024

Added PR description

@kienbd kienbd marked this pull request as ready for review September 27, 2024 06:57
@kienbd kienbd changed the title wip: Keep languages if all Support languages="all" parameter in localize function Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants