Log missing language items as devtools feature
authorMatthias Schmidt <gravatronics@live.com>
Sat, 1 Dec 2018 08:46:29 +0000 (09:46 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Sat, 1 Dec 2018 08:46:29 +0000 (09:46 +0100)
Note: This implementation will be tested first for some time to see how to works out in practice over a longer period of time.

See #2782

com.woltlab.wcf/option.xml
constants.php
wcfsetup/install/files/lib/data/language/Language.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 8aa3596dfb75d46f279f8d04e28a37473e33e63f..8f1f53ca15b63609f2680d0ca11d8f67c6a5ed01 100644 (file)
                                <categoryname>module.development</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
+                               <enableoptions>log_missing_language_items</enableoptions>
                        </option>
                        <!-- general.page -->
                        <option name="page_title">
@@ -1609,6 +1610,11 @@ DESC:wcf.global.sortOrder.descending</selectoptions>
                                <selectoptions>ASC:wcf.global.sortOrder.ascending
 DESC:wcf.global.sortOrder.descending</selectoptions>
                        </option>
+                       <option name="log_missing_language_items">
+                               <categoryname>module.development</categoryname>
+                               <optiontype>boolean</optiontype>
+                               <defaultvalue>0</defaultvalue>
+                       </option>
                </options>
        </import>
        <delete>
index 5dedd54b131e8c38ddc62e1a12ff6232993bd241..3d367c369011e9e8ac4321480b6ee9e47354ce34 100644 (file)
@@ -244,3 +244,4 @@ define('MESSAGE_SIDEBAR_ENABLE_ARTICLES', 1);
 define('IMAGE_PROXY_ENABLE_PRUNE', 1);
 define('SEARCH_ENABLE_PAGES', 1);
 define('SEARCH_ENABLE_ARTICLES', 1);
+define('LOG_MISSING_LANGUAGE_ITEMS', 0);
index a2ca949e9f2575b4e93c6b710f84581abff06aa3..a0a8dd83147a2e93407d8a5a577d3ed972f21da9 100644 (file)
@@ -104,6 +104,14 @@ class Language extends DatabaseObject {
                        return '';
                }
                
+               if (LOG_MISSING_LANGUAGE_ITEMS && preg_match('~^([a-zA-Z0-9-_]+\.)+[a-zA-Z0-9-_]+$~', $item)) {
+                       $logFile = WCF_DIR . 'log/missingLanguageItems.txt';
+                       \wcf\functions\exception\logThrowable(
+                               new \Exception("Missing language item '{$item}'."),
+                               $logFile
+                       );
+               }
+               
                // return plain input
                return $item;
        }
@@ -127,6 +135,14 @@ class Language extends DatabaseObject {
                        return WCF::getTPL()->fetchString($this->dynamicItems[$item], $variables);
                }
                
+               if (LOG_MISSING_LANGUAGE_ITEMS && $staticItem === $item && preg_match('~^([a-zA-Z0-9-_]+\.)+[a-zA-Z0-9-_]+$~', $item)) {
+                       $logFile = WCF_DIR . 'log/missingLanguageItems.txt';
+                       \wcf\functions\exception\logThrowable(
+                               new \Exception("Missing language item '{$item}'."),
+                               $logFile
+                       );
+               }
+               
                return $staticItem;
        }
        
index c9cf1b6baf8dbce07108c863bbedca61c90d47cc..06f1277ceb9bf89239586d6dcba6207a3be7988d 100644 (file)
@@ -1503,6 +1503,8 @@ Als Benachrichtigungs-URL in der Konfiguration der sofortigen Zahlungsbestätigu
                <item name="wcf.acp.option.search_enable_articles"><![CDATA[Artikel sind durchsuchbar]]></item>
                <item name="wcf.acp.option.search_enable_pages"><![CDATA[Seiten sind durchsuchbar]]></item>
                <item name="wcf.acp.option.message_sidebar_enable_articles"><![CDATA[Artikelanzahl der Autoren anzeigen]]></item>
+               <item name="wcf.acp.option.log_missing_language_items"><![CDATA[Fehlende Sprachvariablen protokollieren]]></item>
+               <item name="wcf.acp.option.log_missing_language_items.description"><![CDATA[Die fehlenden Sprachvariablen werden in der Datei <code>{'WCF_DIR'|constant}log/missingLanguageItems.txt</code> protokolliert.]]></item>
        </category>
        <category name="wcf.acp.customOption">
                <item name="wcf.acp.customOption.list"><![CDATA[Eingabefelder]]></item>
index daa695da629c4147828972fd6341865bad700146..814c05a624fc027b09919415404c53e8f8bc9359 100644 (file)
@@ -1493,6 +1493,8 @@ When prompted for the notification URL for the instant payment notifications, pl
                <item name="wcf.acp.option.search_enable_articles"><![CDATA[Articles are searchable]]></item>
                <item name="wcf.acp.option.search_enable_pages"><![CDATA[Pages are searchable]]></item>
                <item name="wcf.acp.option.message_sidebar_enable_articles"><![CDATA[Display author’s article count]]></item>
+               <item name="wcf.acp.option.log_missing_language_items"><![CDATA[Log Missing Language Items]]></item>
+               <item name="wcf.acp.option.log_missing_language_items.description"><![CDATA[The missing language items are logged in the log file <code>{'WCF_DIR'|constant}log/missingLanguageItems.txt</code>.]]></item>
        </category>
        <category name="wcf.acp.customOption">
                <item name="wcf.acp.customOption.list"><![CDATA[Option Fields]]></item>