Browse Source

Enhance tool to clean language files

Laurent Destailleur 9 years ago
parent
commit
d192438eae

+ 47 - 10
dev/translation/sanity_check_en_langfiles.php

@@ -110,8 +110,11 @@ if (empty($files))
 	exit;
 }
 
+$dups=array();
 $exludefiles = array('.','..','README');
 $files = array_diff($files,$exludefiles);
+// To force a file: $files=array('myfile.lang');
+$files = array('admin.lang');
 $langstrings_3d = array();
 $langstrings_full = array();
 foreach ($files AS $file) {
@@ -128,7 +131,7 @@ foreach ($files AS $file) {
 					$langstrings_3d[$path_file['basename']][$line+1]=$row_array[0];
 					$langstrings_3dtrans[$path_file['basename']][$line+1]=$row_array[1];
 					$langstrings_full[]=$row_array[0];
-					$langstrings_dist[$row_array[0]]=$row_array[0];
+					$langstrings_dist[$row_array[0]]=$row;
 				}
 			}
 		}
@@ -244,7 +247,10 @@ if ($web)
 
 if ((! empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($argv[1]) && $argv[1]=='unused=true'))
 {
-	foreach ($langstrings_dist AS $value)
+    print "***** Strings in en_US that are never used:\n";
+    
+    $unused=array();
+	foreach ($langstrings_dist AS $value => $line)
 	{
 		//$search = '\'trans("'.$value.'")\'';
 	    $search = '-e "\''.$value.'\'" -e \'"'.$value.'"\'';
@@ -252,17 +258,48 @@ if ((! empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($a
 		//print $string."<br>\n";
 		exec($string,$output);
 		if (empty($output)) {
-			$unused[$value] = true;
-			echo $value."<br>\n";
+		    $qualifiedforclean=1;
+		    // Check if we must keep this key to be into file for removal
+		    if (preg_match('/^Module\d+/', $value)) $qualifiedforclean=0;
+		    if (preg_match('/^Permission\d+/', $value)) $qualifiedforclean=0;
+		    if (preg_match('/^PermissionAdvanced\d+/', $value)) $qualifiedforclean=0;
+		    if (preg_match('/^ProfId\d+/', $value)) $qualifiedforclean=0;
+		    if (preg_match('/^Delays_/', $value)) $qualifiedforclean=0;
+		    if (preg_match('/^BarcodeDesc/', $value)) $qualifiedforclean=0;
+		    if (preg_match('/^Extrafield/', $value)) $qualifiedforclean=0;
+		    if (preg_match('/^LocalTax/', $value)) $qualifiedforclean=0;
+		    if (preg_match('/^Country/', $value)) $qualifiedforclean=0;
+		    if (preg_match('/^Civility/', $value)) $qualifiedforclean=0;
+		    if (preg_match('/^Currency/', $value)) $qualifiedforclean=0;
+		    if (preg_match('/^DemandReasonTypeSRC/', $value)) $qualifiedforclean=0;
+		    if (preg_match('/^PaperFormat/', $value)) $qualifiedforclean=0;
+		    if (preg_match('/^Duration/', $value)) $qualifiedforclean=0;
+		    if (preg_match('/^AmountLT/', $value)) $qualifiedforclean=0;
+		    if (preg_match('/^TotalLT/', $value)) $qualifiedforclean=0;
+		    if (preg_match('/^Month/', $value)) $qualifiedforclean=0;
+		    if (preg_match('/^MonthShort/', $value)) $qualifiedforclean=0;
+		    if (preg_match('/^Day\d/', $value)) $qualifiedforclean=0;
+		    
+		    if ($qualifiedforclean)
+		    {
+    			$unused[$value] = $line;
+	       		echo $line;        // $trad contains the \n
+		    }
+		}
+		else 
+		{
+		    unset($output);
+		    //print 'X'.$output.'Y';
 		}
 	}
 
-	if ($web) print "<h2>\n";
-	print "Strings in en_US that are never used\n";
-	if ($web) print "</h2>\n";
-	if ($web) echo "<pre>";
-	print_r($unused);
-	if ($web) echo "</pre>\n";
+	if (empty($unused)) print "No string not used found.\n";
+	else 
+	{
+        $filetosave='/tmp/notused.lang';
+        print "Strings in en_US that are never used are saved into file ".$filetosave.":\n";
+        file_put_contents($filetosave, join("",$unused));
+	}
 }
 
 echo "\n";

+ 0 - 24
htdocs/langs/en_US/accountancy.lang

@@ -9,18 +9,11 @@ ACCOUNTING_EXPORT_DEVISE=Export currency
 Selectformat=Select the format for the file
 ACCOUNTING_EXPORT_PREFIX_SPEC=Specify the prefix for the file name
  
-Accounting=Accounting
-Globalparameters=Global parameters
-Menuaccount=Accounting accounts
-Menuthirdpartyaccount=Thirdparty accounts
-MenuTools=Tools
-
 ConfigAccountingExpert=Configuration of the module accounting expert
 Journaux=Journals
 JournalFinancial=Financial journals
 BackToChartofaccounts=Return chart of accounts
 
-Definechartofaccounts=Define a chart of accounts
 Selectchartofaccounts=Select a chart of accounts
 Addanaccount=Add an accounting account
 AccountAccounting=Accounting account
@@ -31,29 +24,21 @@ Ventilation=Breakdown
 MenuAccountancy=Accountancy
 CustomersVentilation=Breakdown customers
 SuppliersVentilation=Breakdown suppliers
-TradeMargin=Trade margin
 Reports=Reports
-ByCustomerInvoice=By invoices customers
 NewAccount=New accounting account
 Create=Create
 CreateMvts=Create movement
-UpdateAccount=Modification of an accounting account
 UpdateMvts=Modification of a movement
 WriteBookKeeping=Record accounts in general ledger
 Bookkeeping=General ledger
 AccountBalance=Account balance
 
-AccountingVentilation=Breakdown accounting
-AccountingVentilationSupplier=Breakdown accounting supplier
-AccountingVentilationCustomer=Breakdown accounting customer
-
 CAHTF=Total purchase supplier before tax
 InvoiceLines=Lines of invoice to be ventilated
 InvoiceLinesDone=Ventilated lines of invoice
 IntoAccount=Ventilate in the accounting account
 
 Ventilate=Ventilate
-VentilationAuto=Automatic breakdown
 
 Processing=Processing
 EndProcessing=The end of processing
@@ -63,14 +48,10 @@ Lineofinvoice=Line of invoice
 VentilatedinAccount=Ventilated successfully in the accounting account
 NotVentilatedinAccount=Not ventilated in the accounting account
 
-ACCOUNTING_SEPARATORCSV=Column separator in export file
-
 ACCOUNTING_LIMIT_LIST_VENTILATION=Number of elements to be breakdown shown by page (maximum recommended : 50)
 ACCOUNTING_LIST_SORT_VENTILATION_TODO=Begin the sorting of the breakdown pages "Has to breakdown" by the most recent elements
 ACCOUNTING_LIST_SORT_VENTILATION_DONE=Begin the sorting of the breakdown pages "Breakdown" by the most recent elements
 
-AccountLength=Length of the accounting accounts shown in Dolibarr
-AccountLengthDesc=Function allowing to feign a length of accounting account by replacing spaces by the zero figure. This function touches only the display, it does not modify the accounting accounts registered in Dolibarr. For the export, this function is necessary to be compatible with certain software.  
 ACCOUNTING_LENGTH_DESCRIPTION=Length for displaying product & services description in listings (Best = 50)
 ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT=Length for displaying product & services account description form in listings (Best = 50)
 ACCOUNTING_LENGTH_GACCOUNT=Length of the general accounts
@@ -108,9 +89,6 @@ DescPurchasesJournal=Purchases journal
 FinanceJournal=Finance journal
 DescFinanceJournal=Finance journal including all the types of payments by bank account
 
-CashPayment=Cash Payment
-
-SupplierInvoicePayment=Payment of invoice supplier
 CustomerInvoicePayment=Payment of invoice customer
 
 ThirdPartyAccount=Thirdparty account
@@ -125,7 +103,6 @@ DescThirdPartyReport=Consult here the list of the thirdparty customers and the s
 
 ListAccounts=List of the accounting accounts
 
-Pcgversion=Version of the plan
 Pcgtype=Class of account
 Pcgsubtype=Under class of account
 Accountparent=Root of the account
@@ -138,7 +115,6 @@ DescVentilTodoCustomer=Ventilate your lines of customer invoice with an accounti
 ChangeAccount=Change the accounting account for lines selected by the account:
 Vide=-
 DescVentilSupplier=Consult here the annual breakdown accounting of your invoices suppliers
-DescVentilTodoSupplier=Ventilate your lines of invoice supplier with an accounting account
 DescVentilDoneSupplier=Consult here the list of the lines of invoices supplier and their accounting account
 
 ValidateHistory=Validate Automatically

+ 0 - 5
htdocs/langs/en_US/admin.lang

@@ -26,18 +26,15 @@ YourSession=Your session
 Sessions=Users session
 WebUserGroup=Web server user/group
 NoSessionFound=Your PHP seems to not allow to list active sessions. Directory used to save sessions (<b>%s</b>) might be protected (For example, by OS permissions or by PHP directive open_basedir).
-HTMLCharset=Charset for generated HTML pages
 DBStoringCharset=Database charset to store data
 DBSortingCharset=Database charset to sort data
 WarningModuleNotActive=Module <b>%s</b> must be enabled
 WarningOnlyPermissionOfActivatedModules=Only permissions related to activated modules are shown here. You can activate other modules in the Home->Setup->Modules page.
 DolibarrSetup=Dolibarr install or upgrade
-DolibarrUser=Dolibarr user
 InternalUser=Internal user
 ExternalUser=External user
 InternalUsers=Internal users
 ExternalUsers=External users
-GlobalSetup=Global setup
 GUISetup=Display
 SetupArea=Setup area
 FormToTestFileUploadForm=Form to test file upload (according to setup)
@@ -56,9 +53,7 @@ Fiscalyear=Fiscal years
 ErrorReservedTypeSystemSystemAuto=Value 'system' and 'systemauto' for type is reserved. You can use 'user' as value to add your own record
 ErrorCodeCantContainZero=Code can't contain value 0
 DisableJavascript=Disable JavaScript and Ajax functions (Recommended for blind person or text browsers)
-ConfirmAjax=Use Ajax confirmation popups
 UseSearchToSelectCompanyTooltip=Also if you have a large number of third parties (> 100 000), you can increase speed by setting constant COMPANY_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string.
-UseSearchToSelectCompany=Use autocompletion fields to choose third parties instead of using a list box.
 ActivityStateToSelectCompany= Add a filter option to show/hide thirdparties which are currently in activity or has ceased it
 UseSearchToSelectContactTooltip=Also if you have a large number of third parties (> 100 000), you can increase speed by setting constant CONTACT_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string.
 UseSearchToSelectContact=Use autocompletion fields to choose contact (instead of using a list box).