Skip to content

Replace English values in non-English language catalogs with empty strings #4783

Closed

Description

@coderabbitai

Summary

Replace English translation values in non-English language files with ''. Keep translation keys so the application can use its English fallback.

This cleanup is separate from PR #4637, which removes unused Sales language keys.

Scope

  • Audit all language catalogs under app/Language/, excluding app/Language/en/ and app/Language/en-GB/.
  • Replace English translation values in non-English catalogs with ''.
  • Preserve valid localized translations and existing empty-string placeholders.
  • Do not remove translation keys or add guessed translations.
  • Review matching English values in context: identical spelling alone is not sufficient to distinguish untranslated English from valid localized terms, names, or abbreviations.

Examples include rewards_package with the value Rewards in app/Language/tl/Sales.php and app/Language/lo/Sales.php.

Rationale

Non-English catalogs should not store English text as a substitute for a translation. The application's custom language service supports empty-string placeholders and falls back to the English catalog.

Acceptance criteria

  • All non-English language catalogs have been audited for English translation values.
  • Confirmed English translation values are replaced with ''.
  • Existing localized translations and translation keys remain unchanged.
  • English catalogs remain unchanged.
  • Language files remain valid PHP.
  • Representative empty-string entries are checked to confirm English fallback still works.

Context

Requested by @objecttothis.

Leave this issue unassigned.

Activity

  1. objecttothis commented on Oct 28, 2026

    @objecttothis
    Member

    Claude Issue Checker Agent (cc @objecttothis)

    Investigated against current master.

    Status: Still present (audit/cleanup not done).

    This is a repo-wide audit request rather than a single code-path bug, but the specific example cited in the issue reproduces exactly on master:

    • app/Language/tl/Sales.php: 'rewards_package' => 'Rewards', — still the raw English string, not ''.
    • app/Language/lo/Sales.php: 'rewards_package' => 'Rewards', — same, still English.
    • The related rewards_package key in app/Language/tl/Customers.php and app/Language/lo/Customers.php ('Rewards Package') is likewise still untranslated English, confirming the pattern described isn't limited to just the one example given.

    I found no merged or open PR addressing this broad cleanup (searched for PRs referencing #4783 and "non-English" language-catalog audits; the closest matches, #4590 and #4498, are unrelated/already-closed and don't cover this scope). Since this is a large multi-file audit task with explicit acceptance criteria ("[ ]" checkboxes all unchecked), and the cited example is unmodified on master, this issue remains open/unaddressed.

  2. added a commit that references this issue on Nov 4, 2026
    9a304c0
  3. BudsieBuds commented on Nov 4, 2026

    @BudsieBuds
    Member

    @coderabbitai Was this issue resolved and closed rightfully by the linked PR/commits? Please verify all requirements were met and flag any missing parts or regressions.

  4. coderabbitai commented on Nov 4, 2026

    @coderabbitai
    ContributorAuthor
    Analysis chain

    Script executed:

    #!/bin/bash
    set -euo pipefail
    gh api repos/opensourcepos/opensourcepos/issues/4783
    gh api --paginate repos/opensourcepos/opensourcepos/issues/4783/comments
    gh api --paginate repos/opensourcepos/opensourcepos/issues/4783/timeline

    Length of output: 74625


    Script executed:

    #!/bin/bash
    set -euo pipefail
    git status --short
    git rev-parse HEAD
    git remote show origin | head -20
    fd -H '^AGENTS\.md$' -E .git
    fd '^(Sales|Customers|MY_Language)\.php$' app

    Length of output: 3525


    Script executed:

    #!/bin/bash
    set -euo pipefail
    cat AGENTS.md
    git show -s --format='%H %P %s' HEAD
    git diff --stat HEAD^1 HEAD | tail -8
    git diff --name-status -M HEAD^1 HEAD | grep -v '^M[[:space:]]app/Language/' | head -100
    ast-grep outline app/Libraries/MY_Language.php
    ast-grep outline tests/LanguageFilesTest.php
    git diff HEAD^1 HEAD -- app/Libraries/MY_Language.php app/Language/en app/Language/en-GB
    rg -n -C2 "'rewards_package'\s*=>" app/Language/tl/Sales.php app/Language/lo/Sales.php app/Language/tl/Customers.php app/Language/lo/Customers.php

    Length of output: 215186


    Script executed:

    #!/bin/bash
    set -euo pipefail
    gh pr view 4793 --repo opensourcepos/opensourcepos --json title,body,mergedAt,mergeCommit,commits,statusCheckRollup
    gh api --paginate repos/opensourcepos/opensourcepos/issues/4793/comments --jq '.[] | {html_url,body}'
    gh api --paginate repos/opensourcepos/opensourcepos/pulls/4793/reviews --jq '.[] | {state,body,html_url}'

    Length of output: 100832


    Script executed:

    #!/bin/bash
    set -euo pipefail
    nl -ba app/Libraries/MY_Language.php
    nl -ba tests/LanguageFilesTest.php | sed -n '1,200p'
    git diff HEAD^ HEAD -- app/Config/App.php app/Helpers/locale_helper.php app/Views
    rg -n -C2 'MY_Language|fallback|getLine\(' tests --glob '*.php'
    python - <<'PY'
    import pathlib,re,subprocess,collections,json
    root=pathlib.Path('app/Language')
    pat=re.compile(r"""^\s*'((?:\\.|[^'\\])*)'\s*=>\s*(['"])((?:\\.|(?!\2).)*)\2,?\s*$""",re.M)
    def parse(s): return {m[0]:m[2] for m in pat.findall(s)}
    before={}
    # Read all parent blobs in one git process.
    names=subprocess.check_output(['git','ls-tree','-r','--name-only','HEAD^','--','app/Language'],text=True).splitlines()
    names=[n for n in names if n.endswith('.php')]
    proc=subprocess.Popen(['git','cat-file','--batch'],stdin=subprocess.PIPE,stdout=subprocess.PIPE)
    for n in names:
     proc.stdin.write(('HEAD^:'+n+'\n').encode());proc.stdin.flush()
     header=proc.stdout.readline().split();size=int(header[2]);data=proc.stdout.read(size);proc.stdout.read(1)
     before[n]=parse(data.decode())
    proc.stdin.close();proc.wait()
    after={str(p):parse(p.read_text()) for p in root.glob('*/*.php')}
    unparsed=[]
    for p in root.glob('*/*.php'):
     declared=re.findall(r"^\s*'((?:\\.|[^'\\])*)'\s*=>",p.read_text(),re.M)
     if len(declared)!=len(after[str(p)]):unparsed.append(str(p))
    print('FILES',len(after),'LOCALES',len({p.split('/')[2] for p in after}),'PARSE_MISMATCH',unparsed)
    counts=collections.Counter(); residual=[];cleared_different=[];removed=collections.Counter();dupes=[];parity=[]
    for n,new in sorted(after.items()):
     locale=n.split('/')[2];file=n.split('/')[-1]
     old=before.get(n.replace('/hr/','/hr-HR/'),{})
     en=after['app/Language/en/'+file];olden=before.get('app/Language/en/'+file,{})
     if set(new)!=set(en):parity.append((n,sorted(set(new)^set(en))))
     for k in old.keys()-new.keys():removed[(file,k)]+=1
     if locale in ('en','en-GB'):continue
     for k,v in new.items():
      ov=old.get(k)
      if v=='' and ov not in ('',None):
       counts['nonempty_to_empty']+=1
       if ov!=olden.get(k) and ov!=en.get(k):cleared_different.append((n,k,ov,olden.get(k)))
      if v and v==en.get(k) and re.search('[A-Za-z]',v):
       residual.append((n,k,v))
    print('KEY_PARITY_ISSUES',parity)
    print('COUNTS',dict(counts))
    print('REMOVED_KEY_CATEGORIES',json.dumps([(f,k,c) for (f,k),c in removed.items()],ensure_ascii=False))
    print('RETAINED_ENGLISH_IDENTICAL',len(residual))
    for row in residual: print('RETAINED',json.dumps(row,ensure_ascii=False))
    print('CLEARED_DIFFERENT_FROM_ENGLISH',len(cleared_different))
    for row in cleared_different[:160]:print('CLEARED',json.dumps(row,ensure_ascii=False))
    PY

    Length of output: 56102


    Script executed:

    #!/bin/bash
    set -euo pipefail
    python - <<'PY'
    import pathlib,re,subprocess,collections,json
    root=pathlib.Path('app/Language')
    pat=re.compile(r"""^\s*'((?:\\.|[^'\\])*)'\s*=>\s*(['"])((?:\\.|(?!\2).)*)\2,?\s*$""",re.M)
    def parse(s):return {m[0]:m[2] for m in pat.findall(s)}
    after={str(p):parse(p.read_text()) for p in root.glob('*/*.php')}
    print('SHARED LOCALIZED TERMS BEFORE AND AFTER')
    for locale,file,keys in [('fr','Common.php',['date','description','total_spent','logo']),('de-DE','Customers.php',['mailchimp_status']),('id','Common.php',['email','logo']),('id','Calendar.php',['april']),('fr','Config.php',['email_protocol'])]:
     n=f'app/Language/{locale}/{file}'
     old=parse(subprocess.check_output(['git','show','HEAD^:'+n],text=True))
     for k in keys:
      print(n,k,'BEFORE',repr(old.get(k)),'AFTER',repr(after[n].get(k)))
    english_empty=[];ascii_phrases=[]
    for n,new in sorted(after.items()):
     locale=n.split('/')[2];file=n.split('/')[-1]
     if locale in ('en','en-GB'):continue
     old=parse(subprocess.check_output(['git','show','HEAD^:'+n.replace('/hr/','/hr-HR/')],text=True))
     en=after['app/Language/en/'+file]
     for k,v in new.items():
      if v=='' and old.get(k) and en.get(k)=='':
       english_empty.append((n,k,old[k]))
      if v and len(re.findall(r'[A-Za-z]{2,}',v))>=2 and all(ord(c)<128 for c in v) and file!='Calendar.php':
       ascii_phrases.append((n,k,v))
    print('CLEARED WITH EMPTY ENGLISH SOURCE',len(english_empty))
    for r in english_empty:print(json.dumps(r,ensure_ascii=False))
    print('REMAINING ASCII PHRASES',len(ascii_phrases))
    for r in ascii_phrases[:100]:print(json.dumps(r,ensure_ascii=False))
    PY
    rg -n -C3 "customer_sales_tax_support|lang\('Items.tax_percent'|lang\('Config.customer_sales_tax_support'" app --glob '!app/Language/**'
    rg -n -C2 "'(date|logo|mailchimp_status|email|tax_percent|customer_sales_tax_support)'\s*=>" app/Language/fr/Common.php app/Language/de-DE/Customers.php app/Language/id/Common.php app/Language/en/Items.php app/Language/en/Config.php app/Language/bg/Config.php
    fd '^Services\.php$' app
    rg -n -C4 'MY_Language|function language\s*\(' app/Config
    git diff --numstat HEAD^ HEAD -- app/Language/en app/Language/en-GB

    Length of output: 24109


    @BudsieBuds PR #4793 delivered the main cleanup, but I cannot confirm that #4783 met all acceptance criteria. The merge also removed valid localized values.

    I compared commit 9a304c0 with its parent. This is the commit that closed the issue. The earlier “still present” comment predates this merge.

    Acceptance criteria

    Requirement Result
    Audit all non-English catalogs The cleanup spans the catalogs. I inspected 1,104 PHP catalogs across 46 locales, including both English locales. This verifies structural coverage, not a complete linguistic audit.
    Replace confirmed English values with '' Substantially implemented. The merge cleared 6,071 nonempty values outside en and en-GB. All four cited rewards_package entries in Tagalog and Lao are now ''.
    Preserve localized translations and keys Not fully met. Valid shared-language terms were cleared. Keys were also removed.
    Leave English catalogs unchanged Not met literally. The merge changed 14 en catalogs and all 24 en-GB catalogs. These changes include deliberate fixes and broader cleanup.
    Keep valid PHP Supported by successful PR lint checks for PHP 8.2–8.5. The PHPUnit matrix also passed.
    Check representative English fallbacks Runtime verification remains inconclusive. The implementation supports fallback, but the added catalog tests do not exercise it.

    Missing parts and risks

    1. Restore valid localized terms that happen to match English.

    The issue explicitly requires contextual review of identical spelling. These existing values were changed to '':

    Fallback currently displays the same text for these examples. However, the merge removes valid localized values and makes them depend on future English wording. That violates the preservation requirement even without an immediate visual change.

    2. Separate scope changes from completion of the original requirements.

    The merge removed nine keys from every locale, including Common.copyrights, Common.software_title, and Item_kits.item_number_duplicate. It also changed English source text and normalized en-GB.

    These changes are documented in the PR. They are not automatically defects. However, the original “preserve keys” and “English catalogs unchanged” criteria cannot be marked as passed without an explicit scope revision. Current key parity passes because the same keys were removed from English too.

    3. Complete the fallback verification.

    MY_Language::getLine(), Line 31–35 handles empty-string fallback. The language service uses this class. However, LanguageFilesTest.php checks parsing, keys, ordering, duplicates, and locale registration—not fallback output.

    Six cleared entries also have empty English source values. Those entries cannot produce nonempty fallback text. I did not establish an active UI caller for them, so this is not a confirmed UI regression.

    Recommendation

    Do not treat all requirements as verified. Restore the valid shared-language terms, reconcile the expanded scope with the acceptance criteria, and retry representative fallback checks in the normal application environment. Include Tagalog/Lao rewards labels and a formatted string with placeholders.

    The staging deployment failed, so it supplies no additional runtime assurance. I did not execute repository code or tests locally.

    I used the retrieved localization guidance to treat '' as intentional fallback and to avoid guessed translations. I left the issue state unchanged.


    Learnings used
    Learnt from: CR
    Repo: opensourcepos/opensourcepos PR: 0
    File: AGENTS.md:0-0
    Timestamp: 2026-10-31T13:57:12.261Z
    Learning: Applies to {app/Language/**,app/Plugins/*/Language/**} : Source excerpt:
    # Agent Instructions
    
    ## Localization
    
    - Never copy English text from a neighboring key as a value for a non-English language file, even if that neighboring key is already untranslated — evaluate each key independently
    
    Learnt from: CR
    Repo: opensourcepos/opensourcepos PR: 0
    File: AGENTS.md:0-0
    Timestamp: 2026-10-31T13:57:12.261Z
    Learning: Applies to {app/Language/**,app/Plugins/*/Language/**} : Source excerpt:
    # Agent Instructions
    
    ## Localization
    
    - Only `app/Language/en/` and `app/Language/en-GB/` should contain English strings
    
    Learnt from: CR
    Repo: opensourcepos/opensourcepos PR: 0
    File: AGENTS.md:0-0
    Timestamp: 2026-10-31T13:57:12.261Z
    Learning: Applies to {app/Language/**,app/Plugins/*/Language/**} : Source excerpt:
    # Agent Instructions
    
    ## Localization
    
    - Non-English files must use an empty string (`''`) as the value when no translation is provided — CodeIgniter automatically falls back to the default (`en`) language. This applies only when a translation genuinely isn't available yet.
    
    Learnt from: objecttothis
    Repo: opensourcepos/opensourcepos PR: 4450
    File: app/Language/de-DE/Sales.php:76-81
    Timestamp: 2026-04-03T08:54:53.158Z
    Learning: In opensourcepos, non-English language files intentionally use empty string values (`""`) for untranslated keys. The custom `app/Libraries/MY_Language.php` class overrides CI4's `Language::getLine()` to fall back to the English translation whenever `$output === NULL || $output === ""`, so empty strings are a valid and deliberate pattern — they should NOT be flagged as missing translations or suggested for removal.
    
    Learnt from: jekkos
    Repo: opensourcepos/opensourcepos PR: 4656
    File: app/Language/en/Error.php:0-0
    Timestamp: 2026-09-14T19:22:58.964Z
    Learning: For OpenSourcePOS language catalogs under `app/Language/`, leave non-English translation changes to localization maintainers when an equivalent translation is not available. Do not replace localized text with guessed translations.
    

    You are interacting with an AI system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions