roykoand opened a new issue, #65229:
URL: https://github.com/apache/airflow/issues/65229

   ### Under which category would you file this issue?
   
   Airflow Core
   
   ### Apache Airflow version
   
   not related to airflow version
   
   ### What happened and how to reproduce it?
   
    ## Steps to reproduce                                                       
                                                                                
                                                                                
            
                     
   ```bash
   breeze ui check-translation-completeness --language pl
   ```
   
   Among the output you will see keys like `dagRun_few`/`dagRun_many`, etc. 
listed as unused:
   ```bash
   Unused keys (not required, can be removed):
   ...
       common.json:
         assetEvent_few
         assetEvent_many
         asset_few
         asset_many
         backfill_few
         backfill_many
         createdAssetEvent_few
         createdAssetEvent_many
         dagRun_few
         dagRun_many
   ```
      
   ## Root cause                                                                
                                                                                
                                                                                
           
                     
   The logic in `expand_plural_keys` 
(`dev/breeze/src/airflow_breeze/commands/ui_commands.py`) skips expanding 
plural forms for a base key when none of the English values for that base 
contain the literal string `{{count}}`:                           
   ```python
   any_has_count = any(COUNT_PLACEHOLDER in en_key_to_value.get(k, "") for k in 
en_keys_for_base)                                                               
                                                                                
       
   if not any_has_count:
       continue
   ```
   
   The English translations for `dagRun` are:                                   
                                                                                
                                                                                
           
   ```json
   {
       "dagRun_one": "Dag Run",                                                 
                                                                                
                                                                                
           
       "dagRun_other": "Dag Runs"
   }
   ```
   
     Neither value contains `{{count}}`, so the script concludes no plural 
expansion is needed for non-English locales and marks `dagRun_few` / 
`dagRun_many` as unused.                                                        
                             
      
     However, i18next uses the `count` option passed to `translate()` for two 
independent purposes:                                                           
                                                                                
               
                     
     1. Plural form selection — choosing `_one`, `_few`, `_many`, `_other` 
based on the numeric value.                                                     
                                                                                
                  
     2. Interpolation — inserting the number into the translated string via 
`{{count}}`.
                                                                                
                                                                                
                                                                                
             
     The script only accounts for purpose 2. Purpose 1 can occur even when 
`{{count}}` never appears in the string value. For example in 
`TriggeredRuns.tsx` 
([link](https://github.com/roykoand/airflow/blob/55a4ecd6be6cec0d7f7850258fbf40f578841785/airflow-core/src/airflow/ui/src/components/Assets/TriggeredRuns.tsx#L54)):
                                                                                
                
   ```typescript
   translate("dagRun_other", { count: dagRuns.length })                         
                                                                                
                                                                                
       
   ```            
     Here `count` is passed solely to trigger plural form selection. For Polish:
     - count: 2 → i18next selects `dagRun_few` ("Wykonania")
     - count: 6 → i18next selects `dagRun_many` ("Wykonań")
                     
     ## Impact                                                                  
                                                                                
                                                                                
             
                     
     Any locale with grammatical plural forms where the count is displayed 
separately (not via `{{count}}` inside the translation string) will have those 
keys incorrectly flagged as unused. Running `--remove-unused` would silently 
delete valid, necessary translations.
   
   ### What you think should happen instead?
   
   I suggest a bit more accurate heuristic for 
`check-translation-completeness`: if a key base already has multiple English 
plural forms (e.g. `dagRun_other` or `dagRun_one` exist in English), treat it 
as a plural key requiring all forms for the target language — regardless of 
whether `{{count}}` appears in the values.
   
   ### Operating System
   
   _No response_
   
   ### Deployment
   
   None
   
   ### Apache Airflow Provider(s)
   
   _No response_
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Official Helm Chart version
   
   Not Applicable
   
   ### Kubernetes Version
   
   _No response_
   
   ### Helm Chart configuration
   
   _No response_
   
   ### Docker Image customizations
   
   _No response_
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to