Repository navigation
Translate missing strings in multiple languages - #4453
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
✅ Files skipped from review due to trivial changes (9)
📝 WalkthroughWalkthroughAdds many new calendar localization files across multiple locales and fills or adds numerous translation keys (Common, Employees, Items, Reports, Sales) in various language packs, replacing empty strings with localized text and introducing UBL/report labels and validation messages. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 13
🧹 Nitpick comments (2)
app/Helpers/tabular_helper.php (1)
127-130: Harden_blanklink withrelattribute.Add
rel="noopener noreferrer"to prevent tabnabbing risks on new-tab links.Suggested diff
- ['title' => lang('Sales.download_ubl'), 'target' => '_blank'] + ['title' => lang('Sales.download_ubl'), 'target' => '_blank', 'rel' => 'noopener noreferrer']🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/Helpers/tabular_helper.php` around lines 127 - 130, The anchor that opens UBL invoices in a new tab (the array with 'title' => lang('Sales.download_ubl'), 'target' => '_blank') must include the rel attribute to mitigate tabnabbing; update the attributes array used to create the link (in tabular_helper.php where the anchor for "$controller/getUBLInvoice/$sale->sale_id" is built) to add 'rel' => 'noopener noreferrer' alongside 'target' => '_blank'.tests/Libraries/InvoiceAttachment/UblAttachmentTest.php (1)
96-102: Add one success-path XML assertion.This only proves that invalid input returns
null. A minimal happy-path fixture would lock down the generated XML and catch regressions in the new serializer much earlier.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@app/Controllers/Sales.php`:
- Around line 916-930: generateAttachments() can return an empty array for
non-invoice types when invoice_format is 'ubl_only', making emails unsendable;
modify the send flow after calling
InvoiceAttachmentGenerator::generateAttachments($sale_data, $type) to check if
$attachments is empty and if $this->getSendPdf($type) returns true then create a
PDF fallback attachment (e.g., by calling the InvoiceAttachmentGenerator to
produce a PDF or using the existing PDF creation routine) before calling
$this->email_lib->sendEmail / sendMultipleAttachments; ensure
InvoiceAttachmentGenerator::cleanup($attachments) still runs in the finally
block and that the fallback attachment is included in $attachments when sending.
In `@app/Helpers/country_helper.php`:
- Around line 165-175: The ISO-code handling is currently after the
fuzzy/partial match loop which causes short inputs like "US" to be matched
incorrectly; move the ISO-code check (the preg_match('/^[A-Z]{2}$/i',
$normalized) block that returns strtoupper($normalized)) to run before the
foreach that iterates $countryMap, so that direct ISO inputs are returned
immediately and only non-ISO values fall through to the partial-match logic
using $countryMap and stripos comparisons.
- Around line 200-227: The current fallback returns 'EUR' when $currencyMap
lacks an entry for $countryCode, which can silently produce incorrect ISO 4217
values; update the logic in country_helper (the $currencyMap and the return
using $countryCode / getCountryCode()) to stop defaulting to 'EUR' — instead
return null (or throw) so callers can handle missing mappings, or implement a
lookup fallback using a reliable source (e.g., PHP Intl or a centralized
currency mapping service) and use that value; ensure callers of this helper
handle a null/exception return accordingly.
In `@app/Language/fr/Reports.php`:
- Line 149: The translation for the key "toggle_cost_and_profit" uses "Profit"
while the file already uses "Bénéfice" for the "profit" key; update the value
for "toggle_cost_and_profit" to use "Bénéfice" (e.g., change "Basculer Coût &
Profit" to use "Bénéfice") so both keys ("toggle_cost_and_profit" and "profit")
use consistent French terminology.
In `@app/Language/it/Common.php`:
- Line 63: Update the Italian translation for the key phone_number_required in
Common.php to use correct grammar; replace the current value ("Numero di
Telefono è richiesto") with the natural UI copy "Il numero di telefono è
richiesto" so the array entry for "phone_number_required" reads the corrected
sentence.
- Line 54: The "manager" translation entry in Common.php is left in English;
update the translation value for the "manager" key to an Italian term (e.g.,
"Responsabile" or the project-preferred equivalent) so the role labels remain
localized, i.e., change the array entry with key "manager" to use the chosen
Italian label.
In `@app/Language/km/Sales.php`:
- Line 225: The translation key "sale_not_found" in app/Language/km/Sales.php is
currently an empty string; replace it with a non-empty Khmer translation (or a
temporary English fallback like "Sale not found") so lookup failures don't show
a blank message—update the value for the "sale_not_found" array entry and save
the file.
In `@app/Language/ml/Sales.php`:
- Line 225: The "sale_not_found" key in the language array currently has an
empty value; replace the empty string for the "sale_not_found" entry in
Sales.php with an appropriate Malayalam message (e.g., a short, user-facing
error like "വിൽപ്പന കണ്ടെത്തിയില്ല") ensuring proper UTF-8 encoding and correct
PHP string quoting/escaping to match the surrounding array style so the array
syntax (and any trailing commas) remains valid.
In `@app/Language/ta/Sales.php`:
- Line 225: The translation key "sale_not_found" in Language/ta/Sales.php is set
to an empty string which causes blank UI text; update the "sale_not_found" value
to an appropriate Tamil message (for example, "விற்பனை காணப்படவில்லை") by
replacing the empty string in the "sale_not_found" entry in the Sales.php
translations array and follow the same quoting/formatting style as the
surrounding entries.
In `@app/Language/ur/Sales.php`:
- Line 225: The translation key "sale_not_found" is currently an empty string
which yields a blank error in the UI; update the array entry for
"sale_not_found" to a non-empty message (either the correct Urdu translation or
a temporary English fallback like "Sale not found") so not-found flows display a
meaningful error; locate and edit the "sale_not_found" entry in the language
array in the Sales language file and replace "" with the chosen message.
In `@app/Libraries/UBLGenerator.php`:
- Around line 206-214: The current code sets
LegalMonetaryTotal::setPayableAmount using post-payment balance
($saleData['amount_due']) computed in _load_sale_data(), which can be zero or
negative for paid sales; change it to use the invoice total instead (the same
value used for setTaxInclusiveAmount) by passing (float)$total to
setPayableAmount (update the call in the LegalMonetaryTotal chain where
setPayableAmount((float)$amountDue) currently appears), ensuring PayableAmount
reflects the invoice total rather than the remaining balance after payments.
- Around line 57-77: The code hard-codes the supplier country to 'BE' and uses
config['account_number'] for PartyTaxScheme::setCompanyId; update it to read the
country and tax identifier from the config instead. In the block that builds
Country and Address (using parseAddress, Country, Address, Party) replace the
fixed 'BE' with a config value (e.g. $config['country'] or
$config['country_code'] with a sensible default) and when creating
PartyTaxScheme (PartyTaxScheme and setCompanyId) pass the supplier tax id field
from config (e.g. $config['vat_number'] or $config['tax_id']), not
account_number; ensure you still guard with the existing !empty check and keep
other address fields (parseAddress, setPostalAddress) intact.
- Around line 181-191: The project uses BCMath functions (bccomp, bcdiv, bcadd)
in UBLGenerator (around the TaxSubTotal calculation), but the PHP extension is
not declared as a dependency; update composer.json by adding "ext-bcmath": "*"
to the "require" section so Composer enforces installation on developers'
machines and CI, then run composer update / validate to ensure the manifest is
correct.
---
Nitpick comments:
In `@app/Helpers/tabular_helper.php`:
- Around line 127-130: The anchor that opens UBL invoices in a new tab (the
array with 'title' => lang('Sales.download_ubl'), 'target' => '_blank') must
include the rel attribute to mitigate tabnabbing; update the attributes array
used to create the link (in tabular_helper.php where the anchor for
"$controller/getUBLInvoice/$sale->sale_id" is built) to add 'rel' => 'noopener
noreferrer' alongside 'target' => '_blank'.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 05c95ee4-ee44-4ac3-bcfc-57e51ca529b4
📒 Files selected for processing (86)
app/Controllers/Sales.phpapp/Database/Migrations/20260304000000_addUblConfig.phpapp/Helpers/country_helper.phpapp/Helpers/tabular_helper.phpapp/Language/ar-EG/Sales.phpapp/Language/ar-LB/Sales.phpapp/Language/az/Sales.phpapp/Language/bg/Sales.phpapp/Language/bs/Sales.phpapp/Language/ckb/Sales.phpapp/Language/cs/Sales.phpapp/Language/da/Sales.phpapp/Language/de-CH/Sales.phpapp/Language/de-DE/Calendar.phpapp/Language/de-DE/Common.phpapp/Language/de-DE/Employees.phpapp/Language/de-DE/Items.phpapp/Language/de-DE/Reports.phpapp/Language/de-DE/Sales.phpapp/Language/el/Sales.phpapp/Language/en-GB/Sales.phpapp/Language/en/Sales.phpapp/Language/es-ES/Calendar.phpapp/Language/es-ES/Employees.phpapp/Language/es-ES/Items.phpapp/Language/es-ES/Reports.phpapp/Language/es-ES/Sales.phpapp/Language/es-MX/Sales.phpapp/Language/fa/Sales.phpapp/Language/fr/Common.phpapp/Language/fr/Employees.phpapp/Language/fr/Items.phpapp/Language/fr/Reports.phpapp/Language/fr/Sales.phpapp/Language/he/Sales.phpapp/Language/hr-HR/Sales.phpapp/Language/hu/Sales.phpapp/Language/hy/Sales.phpapp/Language/id/Sales.phpapp/Language/it/Common.phpapp/Language/it/Employees.phpapp/Language/it/Items.phpapp/Language/it/Reports.phpapp/Language/it/Sales.phpapp/Language/km/Sales.phpapp/Language/lo/Sales.phpapp/Language/ml/Sales.phpapp/Language/nb/Sales.phpapp/Language/nl-BE/Sales.phpapp/Language/nl-NL/Calendar.phpapp/Language/nl-NL/Common.phpapp/Language/nl-NL/Employees.phpapp/Language/nl-NL/Items.phpapp/Language/nl-NL/Reports.phpapp/Language/nl-NL/Sales.phpapp/Language/pl/Sales.phpapp/Language/pt-BR/Common.phpapp/Language/pt-BR/Employees.phpapp/Language/pt-BR/Items.phpapp/Language/pt-BR/Reports.phpapp/Language/pt-BR/Sales.phpapp/Language/ro/Sales.phpapp/Language/ru/Sales.phpapp/Language/sv/Sales.phpapp/Language/sw-KE/Sales.phpapp/Language/sw-TZ/Sales.phpapp/Language/ta/Sales.phpapp/Language/th/Sales.phpapp/Language/tl/Sales.phpapp/Language/tr/Sales.phpapp/Language/uk/Sales.phpapp/Language/ur/Sales.phpapp/Language/vi/Sales.phpapp/Language/zh-Hans/Sales.phpapp/Language/zh-Hant/Sales.phpapp/Libraries/Email_lib.phpapp/Libraries/InvoiceAttachment/InvoiceAttachment.phpapp/Libraries/InvoiceAttachment/InvoiceAttachmentGenerator.phpapp/Libraries/InvoiceAttachment/PdfAttachment.phpapp/Libraries/InvoiceAttachment/UblAttachment.phpapp/Libraries/UBLGenerator.phpapp/Views/sales/invoice.phpcomposer.jsontests/Libraries/InvoiceAttachment/InvoiceAttachmentGeneratorTest.phptests/Libraries/InvoiceAttachment/PdfAttachmentTest.phptests/Libraries/InvoiceAttachment/UblAttachmentTest.php
- Add Calendar.php translation file for es-ES, nl-NL, de-DE - Fill empty string translations in Common.php for de-DE, nl-NL, fr, it, pt-BR - Translate UBL invoice strings (ubl_invoice, download_ubl, ubl_generation_failed) in Sales.php - Add toggle_cost_and_profit in Reports.php for all languages - Translate error_deleting_admin and error_updating_admin in Employees.php - Translate csv_import_invalid_location error message in Items.php - Update various missing translations for administrator, clerk, manager, dashboard, etc. Languages updated: Spanish (es-ES), Dutch (nl-NL), German (de-DE), French (fr), Italian (it), Portuguese (pt-BR)
feb742e to
97cc39b
Compare
|
@objecttothis This PR attempts to translate any missing strings across multiple language files. I've filled in empty strings with appropriate translations where possible. Note that for languages with non-Latin scripts (Arabic, Chinese, Hebrew, Thai, etc.), the original English strings have been left empty as requested - native speakers would need to provide proper translations. Languages updated: Spanish (es-ES), Dutch (nl-NL), German (de-DE), French (fr), Italian (it), Portuguese (pt-BR). Please review and let me know if any translations need adjustment! |
- Use 'Bénéfice' in French Reports.php for consistency with 'profit' key - Fix Italian grammar: 'Il numero di telefono è richiesto' - Use 'Responsabile' for 'manager' in Italian Common.php - Add 'sale_not_found' translation key to missing languages (km, ml, ta, ur) - Tamil (ta) gets proper translation, others get English fallback
@jekkos thank your for doing this. Do you think we could do the other latin-based languages? Here are the ones that I see: Also, some languages seem to be missing files such as ka, ml, lo, nb, ur... many are missing Calendar.php Another thing to note is that some language have English translations in the phrases instead of "". It would be nice if we could detect that and replace it with the correct translation. See tl for example. |
|
I will do another pass then. I have also asked an agent to go through the issue tracker and do cleanup . now the ollama is 20 dollar a month so trying to put it to good use |
I'd say we are getting pretty good use out of it so far. I wonder if it would help to list the overall monthly costs this project has for those interested in donating time or money to keep finding for the project going so that it's not just coming out of your pocket. Also, you might have already done this but Rabbit should be free for OSS projects. |
Use empty strings for sale_not_found in Khmer, Malayalam, and Urdu as these languages cannot be translated by this model.
- es-MX: Spanish (Mexico) calendar translations - nb: Norwegian Bokmål calendar translations - he: Hebrew calendar translations - ml: Malayalam calendar translations - tl: Tagalog calendar translations - ar-EG: Arabic (Egypt) calendar translations - ka, lo, ur: Empty placeholders (cannot translate these languages)
|
I have now asked to cleanup also the issue titles and make them more descriptive, but also apply consistent formatting as we have defined in the templates. This might generate quite some notifications.. so bear with me |
No worries. If there are particular things you need a code review on, then you might want to mention me specifically so that I don't miss it thinking that it was just an agent change. |
|
Calendar.php translations have been added for all missing languages: Fully translated:
Left empty for native speakers:
These languages use scripts that cannot be accurately translated by this model and should be completed by native speakers. |
|
@jekkos all these changes look good. Do you want me to submit a code review or are you planning to have an agent populate missing translations in latin languages still? |
|
Have the impression that glm model can not translate it. I might try another one at some point. If it is fine then lets merge |
Summary
This PR adds missing translations and fills in empty strings in several language files for OSPOS. The translations follow the existing patterns in each language file and maintain consistency with terminology already in use.
Changes
New Files
Calendar.phptranslation file for:Updated Files
Common.php
admin,clerk,color,dashboard,fields_required_message_unique,gender_undefined,logo,logo_mark,manager,no,people,phone_number_required,position,software_short,software_title,yes,you_are_using_osposEmployees.php
administrator,change_employee,clerk,commission,error_deleting_admin,error_updating_admin,managerSales.php
ubl_invoicedownload_ublubl_generation_failedReports.php
toggle_cost_and_profitItems.php
csv_import_invalid_locationerror messageLanguages Updated
Testing
Please verify the translations are accurate and contextually appropriate for each language.
Summary by CodeRabbit