1.x Atlas -
+ + i18n. See upgrade-from-1.0.txt for more details.
1.0 Lykos - 2022-11-12
- - Initial release
+ + Initial release
--- /dev/null
+Other languages are supported by the i18n ini files in the lib/i18n folder.
+It uses the two char lang code as a filename.
+
+To add a new translation copy the existing en.ini file and rename it to the new language.
+Edit every value for each key in the file. Get in touch or even make a PR via github to
+get the new language added.
\ No newline at end of file
--- /dev/null
+New config for i18n. Open config.php and add the following:
+
+# language settings
+const FRONTEND_LANGUAGE = 'en';
+
+currently only en (default) and de are available.
\ No newline at end of file
# timezone settings
const TIMEZONE = 'Europe/Berlin';
+# language settings
+const FRONTEND_LANGUAGE = 'en';
+
# path settings
const PATH_ABSOLUTE = '/home/banana/code/scientia/webroot';
const PATH_SYSTEMOUT = PATH_ABSOLUTE . '/systemout';
# required libs
require_once('lib/summoner.class.php');
+require_once('lib/i18n.class.php');
Summoner::simpleAuth();
+# i18n
+$i18n = new I18n();
+
# database object
$DB = false;
--- /dev/null
+<?php
+/**
+ * scientia
+ *
+ * Copyright 2022 Johannes Keßler
+ *
+ * https://www.bananas-playground.net/projekt/scientia/
+ *
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE
+ *
+ * You should have received a copy of the
+ * COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+ * along with this program. If not, see http://www.sun.com/cddl/cddl.html
+ */
+
+class I18n {
+ /**
+ * @var string The lang code
+ */
+ private $_defaultLangToUse = 'en';
+
+ /**
+ * @var array The loaded lang information from the file
+ */
+ private $_langData = array();
+
+ /**
+ * i18n constructor.
+ */
+ public function __construct() {
+ $_langFile = ABSOLUTE_PATH.'/lib/i18n/'.$this->_defaultLangToUse.'.ini';
+ if(defined('FRONTEND_LANGUAGE')) {
+ $_langFile = ABSOLUTE_PATH.'/lib/i18n/'.FRONTEND_LANGUAGE.'.ini';
+ if(file_exists($_langFile)) {
+ $_langData = parse_ini_file($_langFile);
+ if($_langData !== false) {
+ $this->_langData = $_langData;
+ }
+ }
+ }
+ else {
+ $_langData = parse_ini_file($_langFile);
+ if($_langData !== false) {
+ $this->_langData = $_langData;
+ }
+ }
+ }
+
+ /**
+ * Return text for given key for currently loaded lang
+ *
+ * @param string $key
+ * @return string
+ */
+ public function t(string $key): string {
+ $ret = $key;
+ if(isset($this->_langData[$key])) {
+ $ret = $this->_langData[$key];
+ }
+ return $ret;
+ }
+}
\ No newline at end of file
--- /dev/null
+; scientia
+;
+; Copyright 2022 Johannes Keßler
+;
+; https://www.bananas-playground.net/projekt/scientia/
+;
+;
+; This program is free software: you can redistribute it and/or modify
+; it under the terms of the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE
+;
+; You should have received a copy of the
+; COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+; along with this program. If not, see http://www.sun.com/cddl/cddl.html
--- /dev/null
+; scientia
+;
+; Copyright 2022 Johannes Keßler
+;
+; https://www.bananas-playground.net/projekt/scientia/
+;
+;
+; This program is free software: you can redistribute it and/or modify
+; it under the terms of the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE
+;
+; You should have received a copy of the
+; COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+; along with this program. If not, see http://www.sun.com/cddl/cddl.html
+
+form.button.save=Save
+form.button.search=Search
+form.checkbox.deleteentry=Delete Entry
+
+
+text.new=New
+text.home=Home
+text.noentries=Nothing here.
+
<?php } ?>
<form method="post">
<textarea rows="25" placeholder="write here" name="fdata[entry]"><?php echo Summoner::ifset($TemplateData['data'],'body'); ?></textarea>
- <input type="submit" name="submitForm" value="Save">
- <input type="checkbox" name="deleteEntry" value="yes" /> <small style="color: indianred">Delete Entry</small>
+ <input type="submit" name="submitForm" value="<?php echo $i18n->('form.button.save'); ?>">
+ <input type="checkbox" name="deleteEntry" value="yes" /> <small style="color: indianred"><?php echo $i18n->('form.checkbox.deleteentry'); ?></small>
</form>
<p>
-<a href="<?php echo PATH_WEBROOT; ?>">Home</a>
+<a href="<?php echo PATH_WEBROOT; ?>"><?php echo $i18n->('text.home'); ?></a>
<?php if(!empty($TemplateData['data'])) {
echo ' | ';
$_link = '';
echo '<a href="'.PATH_WEBROOT.$_link.'">'.$be.'</a> | ';
}
?>
- <a href="<?php echo PATH_WEBROOT; ?>/new">New</a>
+ <a href="<?php echo PATH_WEBROOT; ?>/new"><?php echo $i18n->('text.new'); ?></a>
<?php } ?>
</p>
<form method="post">
<input type="text" name="searchInput" size="50" />
- <input type="submit" name="submitForm" value="Search">
+ <input type="submit" name="submitForm" value="<?php echo $i18n->('form.button.search'); ?>">
</form>
<p>
- <a href="<?php echo PATH_WEBROOT; ?>/">Home</a> | <a href="<?php echo PATH_WEBROOT; ?>/new">New</a>
+ <a href="<?php echo PATH_WEBROOT; ?>/"><?php echo $i18n->('text.home'); ?></a> | <a href="<?php echo PATH_WEBROOT; ?>/new"><?php echo $i18n->('text.new'); ?></a>
</p>
<?php if(!empty($TemplateData['entries'])) { ?>
<?php
<?php
}
} else { ?>
-<p>Nothing here.</p>
+<p><?php echo $i18n->('text.noentries'); ?></p>
<?php } ?>