Skip to content

Allow values: empty string, 0 and false (valid JSON values)#928

Open
Zefling wants to merge 1 commit into
jsverse:masterfrom
Zefling:patch-1
Open

Allow values: empty string, 0 and false (valid JSON values)#928
Zefling wants to merge 1 commit into
jsverse:masterfrom
Zefling:patch-1

Conversation

@Zefling

@Zefling Zefling commented Jun 3, 2026

Copy link
Copy Markdown

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #927

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information


Summary by cubic

Allow empty string, 0, and false translation values to be returned instead of treated as missing. Fixes incorrect missing-key handling for valid JSON values.

  • Bug Fixes
    • In TranslocoService, use isDefined from @jsverse/utils when checking resolved keys so only undefined/null trigger the missing key handler.

Written for commit 76eb994. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Fixed translation service to properly handle falsy values (such as 0, empty strings, or false) — they are now correctly displayed instead of being treated as missing translations.

@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0e003e7a-ce2f-4fdd-8c9b-5e6a21137ac4

📥 Commits

Reviewing files that changed from the base of the PR and between 82ae7bb and 76eb994.

📒 Files selected for processing (1)
  • libs/transloco/src/lib/transloco.service.ts

📝 Walkthrough

Walkthrough

TranslocoService's translate() method now uses a definedness check instead of a falsy check to detect missing translations. An import for isDefined from @jsverse/utils enables the refined logic, distinguishing undefined from other falsy values like empty strings.

Changes

Missing Translation Detection

Layer / File(s) Summary
Definedness-based missing value check
libs/transloco/src/lib/transloco.service.ts
isDefined is imported and replaces the falsy truthiness check in the translate() missing-value branch, so only undefined triggers missing-key handling rather than all falsy values.

Fun fact: In internationalization, the empty string "" can be a valid translation—for example, in some languages or contexts, certain UI elements intentionally display nothing. With this change, Transloco now correctly treats an empty string translation as valid rather than missing! 🌍

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: allowing empty string, 0, and false as valid translation values instead of treating them as missing.
Description check ✅ Passed The PR description follows the template structure with PR Type (Bugfix) and issue reference (#927) completed, though 'What is the new behavior?' section is empty.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new

pkg-pr-new Bot commented Jun 3, 2026

Copy link
Copy Markdown

Open in StackBlitz

@jsverse/transloco

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco@928

@jsverse/transloco-locale

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-locale@928

@jsverse/transloco-messageformat

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-messageformat@928

@jsverse/transloco-optimize

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-optimize@928

@jsverse/transloco-persist-lang

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-persist-lang@928

@jsverse/transloco-persist-translations

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-persist-translations@928

@jsverse/transloco-preload-langs

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-preload-langs@928

@jsverse/transloco-schematics

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-schematics@928

@jsverse/transloco-scoped-libs

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-scoped-libs@928

@jsverse/transloco-utils

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-utils@928

@jsverse/transloco-validator

npm i https://pkg.pr.new/jsverse/transloco/@jsverse/transloco-validator@928

commit: 76eb994

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

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.

1 participant