fix french comments (#39019)

* fix french comments

* Update LangTest.php

* Update originproductline.tpl.php

* Update LanguageOfCommentsSniff.php

* Update LanguageOfCommentsSniff.php

* FIX: Suppress Phan undeclared test-framework warnings in LangTest

* FIX: Correct testTrans return type and non-nullable params in LangTest

* FIX: Declare MoLine::fk_bom_child transient property
This commit is contained in:
Frédéric FRANCE 2026-06-30 12:25:04 +02:00 committed by GitHub
parent 5ac50994e6
commit 57ab98c673
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 28 additions and 17 deletions

View file

@ -24,7 +24,9 @@ use PHP_CodeSniffer\Files\File;
*/
class LanguageOfCommentsSniff implements Sniff
{
// List of words that betray a comment in French
/**
* @var string[] List of words that betray a comment in French
*/
public $frenchWords = [
' additionner ',
' arrondir ',
@ -102,7 +104,7 @@ class LanguageOfCommentsSniff implements Sniff
$contentLower = strtolower($content);
// content contains french examples
if (strpos($contentLower, 'france') !== false || strpos($contentLower, 'french')) {
if (strpos($contentLower, 'france') !== false || strpos($contentLower, 'french') || strpos($content, 'fr_FR')) {
return;
}

View file

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2020 Lenin Rivas <lenin@leninrivas.com>
* Copyright (C) 2023-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2023-2026 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
*
@ -197,6 +197,11 @@ class MoLine extends CommonObjectLine
*/
public $fk_default_workstation;
/**
* @var ?int Id of the child BOM linked to this line (not stored in the line table, set on the fly for display)
*/
public $fk_bom_child;
/**
* Constructor
*

View file

@ -2,7 +2,7 @@
/* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2017 Charlie Benke <charlie@patas-monkey.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -142,7 +142,7 @@ if ($resql) {
$sub_bom_line = new BOMLine($db);
$sub_bom_line->fetch($obj->rowid);
//If hidden conf is set, we show directly all the sub-BOM lines
// If hidden conf is set, we show directly all the sub-BOM lines
if (!getDolGlobalString('BOM_SHOW_ALL_BOM_BY_DEFAULT')) {
print '<tr style="display:none" class="sub_bom_lines" parentid="'.$line->id.'">';
} else {
@ -170,14 +170,14 @@ if ($resql) {
// Unit
print '<td class="linecolunit nowrap right" id="sub_bom_unit_'.$sub_bom_line->id.'">'.measuringUnitString($sub_bom_line->fk_unit, '', null, 1).'</td>';
// Stock réel
// Physical Stock
if ($sub_bom_product->stock_reel > 0) {
print '<td class="linecolstockreel nowrap center" id="sub_bom_stock_reel_'.$sub_bom_product->stock_reel.'">'.$sub_bom_product->stock_reel.'</td>';
} else {
print '<td class="linecolstockreel nowrap center" id="sub_bom_stock_reel_'.$sub_bom_product->stock_reel.'">&nbsp;</td>';
}
// Stock virtuel
// Virtual stock
if ($sub_bom_product->stock_theorique > 0) {
print '<td class="linecolstocktheorique nowrap center" id="sub_bom_stock_theorique_'.$sub_bom_product->stock_theorique.'">'.$sub_bom_product->stock_theorique.'</td>';
} else {

View file

@ -1,8 +1,8 @@
<?php
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2023 Alexandre Janniaux <alexandre.janniaux@gmail.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2023 Alexandre Janniaux <alexandre.janniaux@gmail.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -79,6 +79,10 @@ $conf->global->MAIN_DISABLE_ALL_MAILS = 1;
* @backupGlobals disabled
* @backupStaticAttributes enabled
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
* @phan-file-suppress PhanUndeclaredClass
* @phan-file-suppress PhanUndeclaredExtendedClass
* @phan-file-suppress PhanUndeclaredMethod
* @phan-file-suppress PhanUndeclaredProperty
*/
class LangTest extends CommonClassTest
{
@ -122,13 +126,13 @@ class LangTest extends CommonClassTest
$newlang->setDefaultLang('fr_FR');
$newlang->load("admin");
// ErrorModuleRequirePHPVersion is a string than contains accent é and <b>
// ErrorModuleRequirePHPVersion is a string than contains accent é and <b> (french comment)
// The ->transnoentities() does not escape nothing into entities.
$result = $newlang->transnoentities("ModuleMustBeEnabled", '<b>é</b><span class="red">aaa</span>');
print "result=".$result.PHP_EOL;
$this->assertEquals('Le module <b><b>é</b><span class="red">aaa</span></b> doit être activé', $result, 'Translation transnoentities ko');
// ErrorModuleRequirePHPVersion is a string than contains accent é and <b>
// ErrorModuleRequirePHPVersion is a string than contains accent é and <b> (french comment)
// The ->trans() escapes content into ModuleMustBeEnabled except b, strong, a, i, br and span tags,
// but content of parameters are escaped
$result = $newlang->trans("ModuleMustBeEnabled", '<b>é</b><span class="red">aaa</span>');
@ -310,11 +314,11 @@ class LangTest extends CommonClassTest
* @param string $dict Dictionary file for translation
* @param string $expected Expected translation result
* @param string $key Key for translation
* @param ?string $param1 Parameter 1 for translation
* @param ?string $param2 Parameter 2 for translation
* @return string
* @param string $param1 Parameter 1 for translation
* @param string $param2 Parameter 2 for translation
* @return void
*/
public function testTrans($description, $langcode, $dict, $expected, $key, $param1 = null, $param2 = null)
public function testTrans($description, $langcode, $dict, $expected, $key, $param1 = '', $param2 = ''): void
{
global $conf,$user,$langs,$db;
$conf = $this->savconf;