-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Fix #10621 - Localize checkbox values in PDF templates #10707
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
base: hotfix
Are you sure you want to change the base?
Fix #10621 - Localize checkbox values in PDF templates #10707
Conversation
Previously, checkbox fields in PDF templates always displayed as "true" or "false" in English, regardless of the user's language settings. This fix replaces the hardcoded strings with calls to the translate() function using the existing 'checkbox_dom' language list, ensuring checkbox values are properly localized. - Checkbox values now display as "Yes"/"No" in English - Values are properly translated for other installed language packs - Administrators can customize these values through language files 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes checkbox field localization in PDF templates by replacing hardcoded "true"/"false" strings with translatable values using the existing 'checkbox_dom' language list.
- Replaces hardcoded "true" string with translate() call for checked checkboxes
- Replaces hardcoded "false" string with translate() call for unchecked checkboxes
- Uses existing 'checkbox_dom' translation keys for consistent localization
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
} elseif ($field_def['type'] == 'bool') { | ||
if ($focus->{$fieldName} == "1") { | ||
$repl_arr[$key . "_" . $fieldName] = "true"; | ||
$repl_arr[$key . "_" . $fieldName] = translate('checkbox_dom', '', '1'); |
Copilot
AI
Aug 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The translate() function calls use magic string keys '1' and '2' without clear documentation of what these keys represent in the checkbox_dom translation list. Consider adding comments to clarify that '1' represents the checked state and '2' represents the unchecked state, or use named constants for better maintainability.
Copilot uses AI. Check for mistakes.
$repl_arr[$key . "_" . $fieldName] = translate('checkbox_dom', '', '1'); | ||
} else { | ||
$repl_arr[$key . "_" . $fieldName] = "false"; | ||
$repl_arr[$key . "_" . $fieldName] = translate('checkbox_dom', '', '2'); |
Copilot
AI
Aug 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The translate() function calls use magic string keys '1' and '2' without clear documentation of what these keys represent in the checkbox_dom translation list. Consider adding comments to clarify that '1' represents the checked state and '2' represents the unchecked state, or use named constants for better maintainability.
Copilot uses AI. Check for mistakes.
Description
Previously, checkbox fields in PDF templates always displayed as "true" or "false" in English, regardless of the user's language settings. This fix replaces the hardcoded strings with calls to the translate() function using the existing 'checkbox_dom' language list, ensuring checkbox values are properly localized.
Motivation and Context
How To Test This
- Go to Admin → PDF Templates (or AOS → PDF Templates)
- Click Create PDF Template
- Select a module that has checkbox fields (e.g., Accounts, Contacts)
- In the template body, add checkbox field variables like:
Active Status: $account_active_c
Email Opt Out: $email_opt_out
Do Not Call: $do_not_call
- Go to the module you selected (e.g., Accounts)
- Create or edit a record
- Set some checkbox fields to checked (Yes) and others unchecked (No)
- Save the record
- Open the record you created
- Click Actions → Print as PDF
- Select your template
- Generate the PDF
- Checkbox values should show as "Yes" or "No" (in English)
- Not as "true", "false", "1", or "0"
- If using other languages, should show localized values
Types of changes
[ X] Bug fix (non-breaking change which fixes an issue)
Final checklist
[ X] My code follows the code style of this project found here.
[X ] I have read the How to Contribute guidelines.