Skip to content

Commit

Permalink
v1.2
Browse files Browse the repository at this point in the history
Add multi lang support
  • Loading branch information
FredBardin committed Jun 7, 2015
1 parent b019bd8 commit d7d9f40
Show file tree
Hide file tree
Showing 16 changed files with 213 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ $RECYCLE.BIN/
*.lnk

# other
.gitignore
*.zip
*.txt
!LICENCE.txt
*.swp
include/config.php
jquery-ui_FULL
Expand Down
10 changes: 5 additions & 5 deletions LICENSE → LICENCE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 FredBardin
Copyright (c) 2015 Frederic Bardin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -9,14 +9,14 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Php web interface to manage Philips Hue lights in a lan.
## Installation
1. Copy 'phpMyHue' directory and its content in your web server.
2. Rename 'include/config.tpl.php' as 'include/config.php'
3. Edit 'include/config.php' and put correct values for '$bridgeip' and '$username'.
3. Edit 'include/config.php' and put correct values for '$bridgeip', '$username' and, if needed, for '$lang' (in reference to an exiting 'text_<lang>.json' file).
brigeip is the ip address of your hue bridge in your lan.
username is a registered user in your hue bridge (cf http://www.developers.meethue.com/documentation/api-core-concepts).

Expand All @@ -17,6 +17,7 @@ username is a registered user in your hue bridge (cf http://www.developers.meeth
* Run effects
* Hue API class available in 'include/hueapi.php' (see comments in file)
* Fully touch device compatible
* Multi Lang
* ...

![screenshot](screen1_pmh.jpg)
Expand Down
4 changes: 3 additions & 1 deletion include/config.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@

$appname = "phpMyHue"; // optional

$apiurl="http://$bridgeip/api/$username";
$apiurl = "http://$bridgeip/api/$username";

$lang = "en";
?>
6 changes: 3 additions & 3 deletions include/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ function display_light_row($prefid,$lnum,$gnum,$cbpos="E",$brislider=false){
// brislider : optional, if true display a brightness slider at the end of a selected row
// -------------------------------------------------------------
function display_lights_groups($prefid="",$cbpos="E",$brislider=false){
global $HueAPI;
global $HueAPI, $trs;

echo "<TABLE CLASS=det_table>";
echo "<THEAD>";
echo "<TR>";
echo "<TD>";
if ($cbpos == "B"){display_lg_checkbox($prefid,"all");}
echo "<TD CLASS=\"label all\"><LABEL FOR=".$prefid."cb_all>All</LABEL>";
echo "<TD CLASS=\"label all\"><LABEL FOR=".$prefid."cb_all>".$trs["All"]."</LABEL>";
echo "<TD><BUTTON ID=".$prefid."allon>On</BUTTON><BUTTON ID=".$prefid."alloff>Off</BUTTON>";
if ($cbpos == "E"){display_lg_checkbox($prefid,"all");}
if ($brislider){display_bri_slider($prefid,"all","all");}
Expand All @@ -107,7 +107,7 @@ function display_lights_groups($prefid="",$cbpos="E",$brislider=false){
echo "<TR CLASS=grp gnum=other>";
echo "<TD><SPAN CLASS=\"grp ui-icon ui-icon-circle-minus\" gnum=other open></SPAN>";
if ($cbpos == "B"){display_lg_checkbox($prefid, "other", "grp", "other");}
echo "<TD CLASS=\"label grp\"><LABEL FOR=".$prefid."cb_other>Lamps</LABEL>";
echo "<TD CLASS=\"label grp\"><LABEL FOR=".$prefid."cb_other>".$trs["Lamps"]."</LABEL>";
echo "<TD><BUTTON ID=".$prefid."otheron>On</BUTTON><BUTTON ID=".$prefid."otheroff>Off</BUTTON>";
if ($cbpos == "E"){display_lg_checkbox($prefid, "other", "grp", "other");}
if ($brislider){display_bri_slider($prefid,"other","other");}
Expand Down
3 changes: 3 additions & 0 deletions include/hueapi.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
// Init env
include "include/config.php";

// Load translations
$trs = json_decode(implode(file('include/text_'.$lang.'.json')),true);

//-- API Class
class HueAPI {
//=====================================
Expand Down
4 changes: 2 additions & 2 deletions include/huecolor.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ function RGBToXy($RGB,$type="bulb"){
// Remark : HueAPI->info must be already set
// ------------------------------------------
function display_light($lnum){
global $HueAPI;
global $HueAPI, $trs;

$linfo = &$HueAPI->info['lights'][$lnum];

Expand All @@ -212,7 +212,7 @@ function display_light($lnum){
$lcolor = "transparent";
if ($lstate['reachable'] == ""){
$unreachable = true;
$popup = " TITLE=\"Unreachable\"";
$popup = " TITLE=\"".$trs["Unreachable"]."\"";
}
} else { // light on : get rgb color
$onoff = "on";
Expand Down
40 changes: 20 additions & 20 deletions include/lights_details.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

// Elements selected and name update if 1 element or color switch if 2 lights selected
echo "\n<DIV ID=dispname><SPAN ID=sellist></SPAN>";
echo "<SPAN ID=selname><INPUT TYPE=text ID=elemname CLASS=ui-corner-all> <BUTTON ID=updname>Rename</BUTTON>";
echo "<SPAN ID=selname><INPUT TYPE=text ID=elemname CLASS=ui-corner-all> <BUTTON ID=updname>".$trs["Rename"]."</BUTTON>";
echo "</SPAN>"; // selname
echo "</DIV>"; // dispname

Expand All @@ -16,7 +16,7 @@
echo "\n<TR>";
echo "<TD rowspan=4><INPUT TYPE=text ID=colorpicker>";
echo "\n<TR ID=trbri>";
echo "<TD CLASS=\"slider slilib\">Brightness";
echo "<TD CLASS=\"slider slilib\">".$trs["Brightness"];
echo "\n<TR ID=trbri>";
echo "<TD CLASS=slider><DIV ID=brislider></DIV></TD>";
echo "<TD><DIV ID=brival CLASS=bsval></DIV>";
Expand All @@ -25,46 +25,46 @@

// Action buttons
echo "\n<DIV ID=actions>";
echo "<FIELDSET CLASS=\"ui-widget ui-widget-content ui-corner-all\"><LEGEND>Effects</LEGEND>\n";
echo "<BUTTON ID=blink1>1 Blink</BUTTON>";
echo "<BUTTON ID=blink30s>Blink 30 s</BUTTON>";
echo "<BUTTON ID=blinkoff>Blink Off</BUTTON>";
echo "<FIELDSET CLASS=\"ui-widget ui-widget-content ui-corner-all\"><LEGEND>".$trs["Effects"]."</LEGEND>\n";
echo "<BUTTON ID=blink1>".$trs["1_Blink"]."</BUTTON>";
echo "<BUTTON ID=blink30s>".$trs["Blink_30_s"]."</BUTTON>";
echo "<BUTTON ID=blinkoff>".$trs["Blink_Off"]."</BUTTON>";
echo "&nbsp;&nbsp;";
echo "<BUTTON ID=colorloop>Color Loop</BUTTON>";
echo "<BUTTON ID=colorloopoff>Loop Off</BUTTON>";
echo "<BUTTON ID=colorloop>".$trs["Color_Loop"]."</BUTTON>";
echo "<BUTTON ID=colorloopoff>".$trs["Loop_Off"]."</BUTTON>";
echo "</FIELDSET>";
echo "\n</DIV>"; // actions

// Transfert color settings
echo "\n<DIV ID=transset>";
echo "<FIELDSET CLASS=\"ui-widget ui-widget-content ui-corner-all\"><LEGEND ID=transsetlegend>Copy color settings</LEGEND>\n";
echo "<FIELDSET CLASS=\"ui-widget ui-widget-content ui-corner-all\"><LEGEND ID=transsetlegend>".$trs["Copy_color_settings"]."</LEGEND>\n";

echo "<DIV ID=tsradio>";
echo "<INPUT TYPE=radio NAME=tsradio ID=cpto VALUE=cpto CHECKED=checked><LABEL FOR=cpto>Copy to</LABEL>";
echo "<INPUT TYPE=radio NAME=tsradio ID=cpfrom VALUE=cpfrom><LABEL FOR=cpfrom>Copy from</LABEL>";
echo "<INPUT TYPE=radio NAME=tsradio ID=swwith VALUE=swwith><LABEL FOR=swwith>Switch with</LABEL>";
echo "<INPUT TYPE=radio NAME=tsradio ID=cpto VALUE=cpto CHECKED=checked><LABEL FOR=cpto>".$trs["Copy_to"]."</LABEL>";
echo "<INPUT TYPE=radio NAME=tsradio ID=cpfrom VALUE=cpfrom><LABEL FOR=cpfrom>".$trs["Copy_from"]."</LABEL>";
echo "<INPUT TYPE=radio NAME=tsradio ID=swwith VALUE=swwith><LABEL FOR=swwith>".$trs["Switch_with"]."</LABEL>";
echo "</DIV>"; // tsradio
echo "&nbsp;<SELECT ID=tssell>\n";
echo "<OPTION VALUE=none>Select light</OPTION>\n";
echo "<OPTION VALUE=none>".$trs["Select_light"]."</OPTION>\n";
foreach ($HueAPI->info['lights'] as $lnum => $lval){
echo "<OPTION VALUE=$lnum>".$lval['name']."</OPTION>\n";
}
echo "</SELECT>\n";

echo "<DIV ID=dtsexec>";
echo "<BUTTON ID=tsexec>Execute</BUTTON>";
echo "<BUTTON ID=tsexec>".$trs["Execute"]."</BUTTON>";
echo "</DIV>"; // dtsexec
echo "\n</FIELDSET>";
echo "\n</DIV>"; // transset

// Group management
echo "\n<DIV ID=grpmgmt>";
echo "<FIELDSET CLASS=\"ui-widget ui-widget-content ui-corner-all\"><LEGEND ID=grplegend>Manage group</LEGEND>\n";
echo "<FIELDSET CLASS=\"ui-widget ui-widget-content ui-corner-all\"><LEGEND ID=grplegend>".$trs["Manage_group"]."</LEGEND>\n";

echo "<SPAN ID=grplightopt>\n";

echo "<SELECT ID=assigngrp>\n";
echo "<OPTION VALUE=other>Select</OPTION>\n";
echo "<OPTION VALUE=other>".$trs["Select"]."</OPTION>\n";
foreach ($HueAPI->info['groups'] as $gnum => $gval){
echo "<OPTION VALUE=$gnum LIGHTS=\"[";
$lightslist = "";
Expand All @@ -74,19 +74,19 @@
}
echo "</SELECT>\n";

echo "<SPAN ID=creategrp> or create <INPUT TYPE=text ID=newgrp CLASS=ui-corner-all></SPAN>\n";
echo "<BUTTON ID=grpassign>Fill Group</BUTTON>\n";
echo "<SPAN ID=creategrp> ".$trs["or_create"]." <INPUT TYPE=text ID=newgrp CLASS=ui-corner-all></SPAN>\n";
echo "<BUTTON ID=grpassign>".$trs["Fill_Group"]."</BUTTON>\n";
echo "</SPAN>\n"; // grplightopt

echo "<SPAN ID=grpopt>\n";
echo "<BUTTON ID=delgrp>Delete group(s)</BUTTON>\n";
echo "<BUTTON ID=delgrp>".$trs["Delete_groups"]."</BUTTON>\n";
echo "</SPAN>\n"; // grpopt

echo "\n</FIELDSET>";
echo "\n</DIV>"; // grpmgmt

// Element description (if 1 element only)
echo "\n<BR><DIV ID=descri><H3>Informations</H3><DIV ID=detdescri></DIV></DIV>";
echo "\n<BR><DIV ID=descri><H3>".$trs["Informations"]."</H3><DIV ID=detdescri></DIV></DIV>";
?>
<SCRIPT>
// Initialize controls
Expand Down
2 changes: 1 addition & 1 deletion include/scenes.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
echo "\n<TR CLASS=radio>";
echo "<TD><SPAN CLASS=\"ui-icon ui-icon-radio-off\"><INPUT TYPE=radio NAME=scradio ID=$sceneid></SPAN>";
echo "<TD CLASS=sname><LABEL FOR=$sceneid>$sname</LABEL>";
echo "<TD><LABEL FOR=$sceneid>&nbsp;Lights: <SPAN>".count($HueAPI->info['scenes'][$sceneid]['lights'])."</SPAN></LABEL>";
echo "<TD><LABEL FOR=$sceneid>&nbsp;".$trs["LightsNB"]." <SPAN>".count($HueAPI->info['scenes'][$sceneid]['lights'])."</SPAN></LABEL>";
}
echo "</TABLE>";
?>
Expand Down
8 changes: 4 additions & 4 deletions include/scenes_details.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

include 'include/functions.php';

echo "\n<FIELDSET CLASS=\"ui-widget ui-widget-content ui-corner-all\"><LEGEND>Save scene with selected lights</LEGEND>";
echo "\n<DIV ID=dispscname>Name <INPUT TYPE=text ID=scname CLASS=ui-corner-all> ";
echo "<BUTTON ID=updscene>Update scene</BUTTON>&nbsp;";
echo "<BUTTON ID=newscene>New scene</BUTTON>";
echo "\n<FIELDSET CLASS=\"ui-widget ui-widget-content ui-corner-all\"><LEGEND>".$trs["Save_scene_with_selected_lights"]."</LEGEND>";
echo "\n<DIV ID=dispscname>".$trs["Name"]." <INPUT TYPE=text ID=scname CLASS=ui-corner-all> ";
echo "<BUTTON ID=updscene>".$trs["Update_scene"]."</BUTTON>&nbsp;";
echo "<BUTTON ID=newscene>".$trs["New_scene"]."</BUTTON>";
echo "</DIV>"; // dispscname
echo "</FIELDSET>";
echo "<BR>";
Expand Down
65 changes: 65 additions & 0 deletions include/text_en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"Lights" : "Lights",
"Lights_&_Groups" : "Lights & Groups",
"Scenes" : "Scenes",
"Scenes_management" : "Scenes management",
"About" : "About",
"About_phpMyHue" : "About phpMyHue",
"All" : "All",
"Lamps" : "Lamps",
"On" : "On",
"Off" : "Off",
"Unreachable" : "Unreachable",
"Selection_details" : "Selection details",
"Element" : "Element",
"Elements" : "Elements",
"All_lamps" : "All lamps",
"Light" : "Light",
"Group" : "Group",
"group" : "group",
"Rename" : "Rename",
"Name_updated" : "Name updated.",
"Brightness" : "Brightness",
"Effect" : "Effect",
"Effects" : "Effects",
"1_Blink" : "1 Blink",
"Blink_30_s" : "Blink 30 s",
"Blink_Off" : "Blink Off",
"Blink_stopped" : "Blink stopped.",
"Color_Loop" : "Color Loop",
"Color_Loop_started" : "Color Loop started.",
"Loop_Off" : "Loop Off",
"Color_Loop_stopped" : "Color Loop stopped.",
"Copy_color_settings" : "Copy color settings",
"Copy_to" : "Copy to",
"Copy_from" : "Copy from",
"Switch_with" : "Switch with",
"Select_light" : "Select light",
"Execute" : "Execute",
"Manage_group" : "Manage group",
"Fill_a_group_with_selected_lamps" : "Fill a group with selected lamp(s)",
"Select" : "Select",
"or_create" : "or create",
"Fill_Group" : "Fill Group",
"Delete_selected_groups" : "Delete selected group(s)",
"Delete_groups" : "Delete group(s)",
"Informations" : "Informations",
"Light_id":"Light id",
"Type":"Type",
"Model_id":"Model id",
"Unique_id":"Unique id",
"Software_version":"Software version",
"LightsNB":"Lights:",
"Save_scene_with_selected_lights" : "Save scene with selected lights",
"Name" : "Name",
"Update_scene" : "Update scene",
"New_scene" : "New scene",
"Scene" : "Scene",
"with_name" : "with name",
"No_light_selected_for_scene" : "No light selected for scene.",
"Scene_name_empty" : "Scene name empty.",
"ERROR" : "ERROR",
"Deleted" : "Deleted.",
"Created" : "Created.",
"Updated" : "Updated."
}
65 changes: 65 additions & 0 deletions include/text_fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"Lights" : "Lum.",
"Lights_&_Groups" : "Lumières & Groupes",
"Scenes" : "Scènes",
"Scenes_management" : "Gestion scènes",
"About" : "A prop",
"About_phpMyHue" : "A propos de phpMyHue",
"All" : "Tout",
"Lamps" : "Lampes",
"On" : "On",
"Off" : "Off",
"Unreachable" : "Inatteignable",
"Selection_details" : "Détails sélection",
"Element" : "Elément",
"Elements" : "Eléments",
"All_lamps" : "Toutes lum.",
"Light" : "Lum.",
"Group" : "Groupe",
"group" : "groupe",
"Rename" : "Renommer",
"Name_updated" : "Nom mis à jour.",
"Brightness" : "Luminosité",
"Effect" : "Effet",
"Effects" : "Effets",
"1_Blink" : "Alarme",
"Blink_30_s" : "Alarme 30 s",
"Blink_Off" : "Fin Alarme",
"Blink_stopped" : "Alarme stoppée.",
"Color_Loop" : "Boucle Couleur",
"Color_Loop_started" : "Boucle couleur demarrée.",
"Loop_Off" : "Fin Boucle",
"Color_Loop_stopped" : "Boucle Couleur stoppée.",
"Copy_color_settings" : "Copier paramètres couleur",
"Copy_to" : "Copier vers",
"Copy_from" : "Copier de",
"Switch_with" : "Echanger avec",
"Select_light" : "Sélection Lum.",
"Execute" : "Exécuter",
"Manage_group" : "Gérer groupe",
"Fill_a_group_with_selected_lamps" : "Remplir un groupe avec lumière(s) sélectionnée(s)",
"Select" : "Sélectionner",
"or_create" : "ou créer",
"Fill_Group" : "Remplir gr",
"Delete_selected_groups" : "Supprimer groupe(s) sélectionne(s)",
"Delete_groups" : "Supprimer groupe(s)",
"Informations" : "Informations",
"Light_id":"Id lumière",
"Type":"Type",
"Model_id":"Id modèle",
"Unique_id":"Id unique",
"Software_version":"Version logiciel",
"LightsNB":"Lum. :",
"Save_scene_with_selected_lights" : "Enregistrer scène avec lumières sélectionnées",
"Name" : "Nom",
"Update_scene" : "MàJ scène",
"New_scene" : "Nouvelle scène",
"Scene" : "Scène",
"with_name" : "avec nom",
"No_light_selected_for_scene" : "Aucune lumière sélectionnée pour la scène.",
"Scene_name_empty" : "Nom de la scène vide.",
"ERROR" : "ERREUR",
"Deleted" : "Supprimé(e).",
"Created" : "Creé(e).",
"Updated" : "Mis(e) à Jour."
}
Loading

0 comments on commit d7d9f40

Please sign in to comment.