Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/nextcloud.com.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2016-10-20 15:22:37 +0300
committerLukas Reschke <lukas@statuscode.ch>2016-10-20 15:22:37 +0300
commit808b0b45ec40e56b4d2e77910eef3963f44ffc60 (patch)
tree714e4db793a3733aeba8871bc9c9f9113e020758 /l10n.php
parentaa4ef66be65155ec950298b735fd7029ac8975b9 (diff)
Inject page name
Diffstat (limited to 'l10n.php')
-rw-r--r--l10n.php13
1 files changed, 9 insertions, 4 deletions
diff --git a/l10n.php b/l10n.php
index cc84eb0b..a51f9ff1 100644
--- a/l10n.php
+++ b/l10n.php
@@ -1,6 +1,13 @@
<?php
class L10N {
+ /** @var string */
+ private $pageName;
+
+ public function __construct($pageName) {
+ $this->pageName = $pageName;
+ }
+
private function getCurrentLanguage() {
// We detect the current language on the hl parameter
if(isset($_GET['hl'])) {
@@ -14,7 +21,7 @@ class L10N {
}
public function t($string) {
- $baseTranslationFile = __DIR__ . '/l10n/base/' . get_post()->post_name . '.json';
+ $baseTranslationFile = __DIR__ . '/l10n/base/' . $this->pageName . '.json';
if(!file_exists($baseTranslationFile)) {
file_put_contents($baseTranslationFile, json_encode([]));
}
@@ -27,7 +34,7 @@ class L10N {
}
// Read the translated string
- $translationFile = __DIR__ . '/l10n/'.$this->getCurrentLanguage().'/' . get_post()->post_name . '.json';
+ $translationFile = __DIR__ . '/l10n/'.$this->getCurrentLanguage().'/' . $this->pageName . '.json';
if(file_exists($translationFile)) {
$translations = json_decode(file_get_contents($translationFile), true);
if(isset($translations[$string])) {
@@ -38,5 +45,3 @@ class L10N {
return $string;
}
}
-
-$l = new L10N(); \ No newline at end of file