Lang MNG
This commit is contained in:
		
							
								
								
									
										41
									
								
								app/class/LangManager.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								app/class/LangManager.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,41 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
* Language Manager
 | 
			
		||||
*/
 | 
			
		||||
class LanguageManager
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	private $lngCode = 'en';
 | 
			
		||||
	private $lngDatabase = [];
 | 
			
		||||
 | 
			
		||||
	function __construct(string $lngCode)
 | 
			
		||||
	{
 | 
			
		||||
		$this->lngCode = $lngCode;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function load()
 | 
			
		||||
	{
 | 
			
		||||
		$file = './app/lang/en.php';
 | 
			
		||||
		$arrayFirst = include($file);
 | 
			
		||||
		$file = './app/lang/' . $this->lngCode . '.php';
 | 
			
		||||
		$arraySecond = include($file);
 | 
			
		||||
		$this->lngDatabase = array_merge($arrayFirst,$arraySecond);
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function get(string $stringKey)
 | 
			
		||||
	{
 | 
			
		||||
		if (isset($this->lngDatabase[$stringKey])) {
 | 
			
		||||
			return $this->lngDatabase[$stringKey];
 | 
			
		||||
		}
 | 
			
		||||
		return $stringKey;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function echo(string $stringKey)
 | 
			
		||||
	{
 | 
			
		||||
		if (isset($this->lngDatabase[$stringKey])) {
 | 
			
		||||
			return $this->lngDatabase[$stringKey];
 | 
			
		||||
		}
 | 
			
		||||
		return $stringKey;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										78
									
								
								app/lang/pl.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								app/lang/pl.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,78 @@
 | 
			
		||||
<?php
 | 
			
		||||
$langMng = [
 | 
			
		||||
	//Menu
 | 
			
		||||
	'm_home' => 'Home',
 | 
			
		||||
	'm_dashboard' => 'Dashboard',
 | 
			
		||||
	'm_settings' => 'Setting',
 | 
			
		||||
	'm_automatization' => 'Automatization',
 | 
			
		||||
	'm_scenes' => 'Scenes',
 | 
			
		||||
	'm_log' => 'Log',
 | 
			
		||||
 | 
			
		||||
	//Buttons
 | 
			
		||||
	'b_year' => 'Year',
 | 
			
		||||
	'b_month' => 'Month',
 | 
			
		||||
	'b_week' => 'Week',
 | 
			
		||||
	'b_day' => 'Day',
 | 
			
		||||
	'b_hour' => 'Hour',
 | 
			
		||||
	'b_next' => 'Next',
 | 
			
		||||
	'b_create' => 'Create',
 | 
			
		||||
	'b_edit' => 'Edit',
 | 
			
		||||
	'b_remove' => 'Remove',
 | 
			
		||||
	'b_approve' => 'Approve',
 | 
			
		||||
	'b_disable' => 'Disable',
 | 
			
		||||
	'b_save' => 'Save',
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	//labels
 | 
			
		||||
	'l_choseDevice' => 'Chose device:',
 | 
			
		||||
	'l_inHome' => 'When entering',
 | 
			
		||||
	'l_outHome' => 'When exiting',
 | 
			
		||||
	'l_sunSet' => 'Sun Set',
 | 
			
		||||
	'l_sunRice' => 'Sun Rise',
 | 
			
		||||
	'l_time' => 'Time',
 | 
			
		||||
	'l_deviceValue' => 'Device Valalue',
 | 
			
		||||
	'l_runAt' => 'Run at',
 | 
			
		||||
	'l_resetAt' => 'Reset at',
 | 
			
		||||
	'l_affectedDevices' => 'Affected devices',
 | 
			
		||||
	'l_atDays' => 'At days',
 | 
			
		||||
	'l_read' => 'Read',
 | 
			
		||||
	'l_use' => 'Use',
 | 
			
		||||
	'l_edit' => 'Edit',
 | 
			
		||||
	'l_owner' => 'Owner',
 | 
			
		||||
	'l_member' => 'Home Member',
 | 
			
		||||
	'l_permission' => 'Permission',
 | 
			
		||||
	'l_inMinutes' => 'in minutes',
 | 
			
		||||
	'l_sleepTime' => 'Device sleep Time',
 | 
			
		||||
	'l_atHome' => 'At home',
 | 
			
		||||
	'l_nameAt' => 'Name',
 | 
			
		||||
 | 
			
		||||
	//Title
 | 
			
		||||
	't_createScene' => 'Create Scene',
 | 
			
		||||
	't_editScene' => 'Edit scénu',
 | 
			
		||||
 | 
			
		||||
	't_createAutomation' => 'Create Automation',
 | 
			
		||||
 | 
			
		||||
	't_editDevice' => 'Edit Device',
 | 
			
		||||
 | 
			
		||||
	//constants
 | 
			
		||||
	'humi' => 'Humidity',
 | 
			
		||||
	'temp' => 'Temperature',
 | 
			
		||||
	'light' => 'Light',
 | 
			
		||||
	'battery' => 'Batteri',
 | 
			
		||||
	'on/off' => 'Switch',
 | 
			
		||||
 | 
			
		||||
	//words
 | 
			
		||||
	'w_title' => 'Name',
 | 
			
		||||
	'w_icon' => 'Icon',
 | 
			
		||||
	'w_no' => 'no',
 | 
			
		||||
	'w_noOne' => 'noone',
 | 
			
		||||
	'w_someOne' => 'Some',
 | 
			
		||||
	'w_room' => 'Room',
 | 
			
		||||
	'w_moduls' => 'Moduls',
 | 
			
		||||
	'w_home' => 'Home',
 | 
			
		||||
	'w_neni' => 'At',
 | 
			
		||||
	'w_is' => 'is',
 | 
			
		||||
 | 
			
		||||
	//example
 | 
			
		||||
	'' => '',
 | 
			
		||||
];
 | 
			
		||||
		Reference in New Issue
	
	Block a user