Skip to content

Commit

Permalink
add language/translation support
Browse files Browse the repository at this point in the history
  • Loading branch information
jradwan committed Jun 10, 2017
1 parent df908aa commit 9779946
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 34 deletions.
50 changes: 30 additions & 20 deletions admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
// debugging messages (for simulation)
array_push(
$page['warnings'],
l10n('Simulation selected')
l10n('MSG_TEST_MODE_ON')
);
}
else
Expand Down Expand Up @@ -97,7 +97,7 @@
{
array_push(
$page['messages'],
l10n('Source and destination are the same. Nothing to do.')
l10n('MSG_NO_WORK')
);
}
else
Expand All @@ -121,11 +121,13 @@
$date_string = preg_replace('/[^\d]/', '', $dbnow);
$dest_file_name = $source_file_name.'-'.$date_string.'.'.$source_file_ext;

// build rename message
$rename_msg = l10n('MESSAGE_RENAME_1').$source_file_name.'.'.$source_file_ext.
l10n('MSG_RENAME_2').$dest_file_name.l10n('MSG_RENAME_3');

array_push(
$page['messages'],
l10n('A file named '.$source_file_name.'.'.$source_file_ext.' already exists in the destination. '.
'The moved file will be renamed to '.$dest_file_name.
' to avoid overwriting the original.')
sprintf($rename_msg)
);
}
else
Expand Down Expand Up @@ -178,8 +180,7 @@
{
array_push(
$page['messages'],
l10n('This file was already virtually linked to the physical destination.'.
' The virtual link has been removed.')
l10n('MSG_LINK_REMOVED')
);
}

Expand Down Expand Up @@ -274,17 +275,17 @@
if ($move_status_ok)
{
// everything successfully moved to destination
$success_msg = l10n('MSG_SUCCESS').$dest_cat_name.'.';
array_push(
$page['infos'],
l10n('File successfully moved to '.$dest_cat_name.'.')
sprintf($success_msg)
);
}
else
{
array_push(
$page['errors'],
l10n('An error occured during the representative/derivatives move. Please check the Piwigo '.
'and web server logs for details.')
l10n('MSG_REP_MOVE_ERR')
);
}

Expand All @@ -294,23 +295,32 @@
{
array_push(
$page['errors'],
l10n('An error occured during the file move. Please check the Piwigo and web server logs for details.')
l10n('MSG_FILE_MOVE_ERR')
);
}

// debugging messages (for simulation)
if ($ppm_test_mode)
{
// build debug strings
$debug_line_1 = l10n('DBG_SRC_ALBUM').$source_cat_name.' (id: '.$storage_cat_id.')';
$debug_line_2 = l10n('DBG_SRC_FILE').$source_file_name.'.'.$source_file_ext;
$debug_line_3 = l10n('DBG_SRC_DIR').$source_dir;
$debug_line_4 = l10n('DBG_SRC_PATH').$source_file_path;
$debug_line_5 = l10n('DBG_DEST_ALBUM').$dest_cat_name.' (id: '.$target_cat.')';
$debug_line_6 = l10n('DBG_DEST_FILE').$dest_file_name;
$debug_line_7 = l10n('DBG_DEST_DIR').$dest_cat_path;
$debug_line_8 = l10n('DBG_DEST_FILE').$dest_file_path;
array_push(
$page['messages'],
l10n('source album: '.$source_cat_name.' (id: '.$storage_cat_id.')'),
l10n('source filename: '.$source_file_name.'.'.$source_file_ext),
l10n('source directory: '.$source_dir),
l10n('source filepath: '.$source_file_path),
l10n('destination album: '.$dest_cat_name.' (id: '.$target_cat.')'),
l10n('destination filename: '.$dest_file_name),
l10n('destination directory: '.$dest_cat_path),
l10n('destination filepath: '.$dest_file_path)
sprintf($debug_line_1),
sprintf($debug_line_2),
sprintf($debug_line_3),
sprintf($debug_line_4),
sprintf($debug_line_5),
sprintf($debug_line_6),
sprintf($debug_line_7),
sprintf($debug_line_8)
);
}
} // move file
Expand All @@ -319,7 +329,7 @@
{
array_push(
$page['messages'],
l10n('No destination selected.')
l10n('MSG_NO_DEST')
);
}

Expand Down
20 changes: 10 additions & 10 deletions admin.tpl
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
<h2>{$TITLE} &#8250; {'Edit photo'|@translate} {$TABSHEET_TITLE}</h2>
<h2>{$TITLE} &#8250; {'EDIT_PHOTO'|@translate} {$TABSHEET_TITLE}</h2>

<fieldset>
<legend>{'Move Photo'|@translate}</legend>
<legend>{'MOVE_PHOTO'|@translate}</legend>
<table>
<tr>
<td id="albumThumbnail" style="vertical-align:top">
<img src="{$TN_SRC}" alt="{'Thumbnail'|@translate}" class="Thumbnail">
<img src="{$TN_SRC}" alt="{'THUMBNAIL'|@translate}" class="Thumbnail">
</td>
<td style="vertical-align:center">
<p style="text-align:left; margin-top:0;">
<strong>{'Current physical album:'|@translate}</strong> {$storage_category}<br>
<strong>{'Current file location:'|@translate}</strong> {$current_path}<br>
<strong>{'CURR_PHYS_ALBUM'|@translate}</strong> {$storage_category}<br>
<strong>{'CURR_FILE_LOC'|@translate}</strong> {$current_path}<br>
</td>
</tr>
</table>
</fieldset>

<form id="ppmove" method="post" action="" enctype="multipart/form-data">
<fieldset id="test_mode">
<legend>{'Simulation'|@translate}</legend>
<label><input type="checkbox" name="test_mode" value="1" {if $ppm_test_mode}checked="checked"{/if} /> {'only perform a simulation (nothing will be changed in the file system or database)'|@translate}</label>
<legend>{'TEST_MODE'|@translate}</legend>
<label><input type="checkbox" name="test_mode" value="1" {if $ppm_test_mode}checked="checked"{/if} /> {'TEST_MODE_DESCR'|@translate}</label>
</fieldset>

<fieldset>
<legend>
Destination Album
<a class="icon-help-circled" title="{'Only other physical albums are listed. Use the \'Linked Albums\' field on the Properties tab to \'move\' this photo into a virtual album.'|@translate}"></a>
{'DEST_ALBUM'|@translate}
<a class="icon-help-circled" title="{'DEST_ALBUM_HELP'|@translate}"></a>
</legend>
<select class="categoryList" name="cat_id" size="10">
{html_options options=$categories selected=$categories_selected}
</select>
<p style="text-align:left"><input class="submit" type="submit" value="{'Move'|@translate}" name="move_photo"></p>
<p style="text-align:left"><input class="submit" type="submit" value="{'MOVE_BUTTON'|@translate}" name="move_photo"></p>
</fieldset>
</form>
1 change: 1 addition & 0 deletions language/en_UK/description.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Move a photo (the actual file) from one physical album to another, preserving all metadata.
32 changes: 32 additions & 0 deletions language/en_UK/plugin.lang.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
$lang['EDIT_PHOTO'] = 'Edit Photo';
$lang['MOVE_PHOTO'] = 'Move Photo';
$lang['THUMBNAIL'] = 'Thumbnail';
$lang['CURR_PHYS_ALBUM'] = 'Current physical album:';
$lang['CURR_FILE_LOC'] = 'Current file location:';
$lang['TEST_MODE'] = 'Simulation';
$lang['TEST_MODE_DESCR'] = 'only perform a simulation (nothing will be changed in the file system or database)';
$lang['DEST_ALBUM'] = 'Destination Album';
$lang['DEST_ALBUM_HELP'] = 'Only other physical albums are listed. Use the \'Linked Albums\' field on the Properties tab to \'move\' this photo into a virtual album.';
$lang['MOVE_BUTTON'] = 'Move';
$lang['MSG_TEST_MODE_ON'] = 'Simulation selected';
$lang['MSG_NO_WORK'] = 'Source and destination are the same. Nothing to do.';
$lang['MSG_RENAME_1'] = 'A file named ';
$lang['MSG_RENAME_2'] = ' already exists in the destination. The moved file will be renamed to ';
$lang['MSG_RENAME_3'] = ' to avoid overwriting the original.';
$lang['MSG_LINK_REMOVED'] = 'This file was already virtually linked to the physical destination. The virtual link has been removed.';
$lang['MSG_REP_MOVE_ERR'] = 'An error occured during the representative/derivatives move. Please check the Piwigo and web server logs for details.';
$lang['MSG_SUCCESS'] = 'File successfully moved to ';
$lang['MSG_FILE_MOVE_ERR'] = 'An error occured during the file move. Please check the Piwigo and web server logs for details';
$lang['MSG_NO_DEST'] = 'No destination selected.';
$lang['DBG_SRC_ALBUM'] = 'source album: ';
$lang['DBG_SRC_FILE'] = 'source filename: ';
$lang['DBG_SRC_DIR'] = 'source directory: ';
$lang['DBG_SRC_PATH'] = 'source filepath: ';
$lang['DBG_DEST_ALBUM'] = 'destination album: ';
$lang['DBG_DEST_FILE'] = 'destination filename: ';
$lang['DBG_DEST_DIR'] = 'destination directory: ';
$lang['DBG_DEST_PATH'] = 'destination filepath: ';


?>
1 change: 1 addition & 0 deletions language/en_US/description.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Move a photo (the actual file) from one physical album to another, preserving all metadata.
32 changes: 32 additions & 0 deletions language/en_US/plugin.lang.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
$lang['EDIT_PHOTO'] = 'Edit Photo';
$lang['MOVE_PHOTO'] = 'Move Photo';
$lang['THUMBNAIL'] = 'Thumbnail';
$lang['CURR_PHYS_ALBUM'] = 'Current physical album:';
$lang['CURR_FILE_LOC'] = 'Current file location:';
$lang['TEST_MODE'] = 'Simulation';
$lang['TEST_MODE_DESCR'] = 'only perform a simulation (nothing will be changed in the file system or database)';
$lang['DEST_ALBUM'] = 'Destination Album';
$lang['DEST_ALBUM_HELP'] = 'Only other physical albums are listed. Use the \'Linked Albums\' field on the Properties tab to \'move\' this photo into a virtual album.';
$lang['MOVE_BUTTON'] = 'Move';
$lang['MSG_TEST_MODE_ON'] = 'Simulation selected';
$lang['MSG_NO_WORK'] = 'Source and destination are the same. Nothing to do.';
$lang['MSG_RENAME_1'] = 'A file named ';
$lang['MSG_RENAME_2'] = ' already exists in the destination. The moved file will be renamed to ';
$lang['MSG_RENAME_3'] = ' to avoid overwriting the original.';
$lang['MSG_LINK_REMOVED'] = 'This file was already virtually linked to the physical destination. The virtual link has been removed.';
$lang['MSG_REP_MOVE_ERR'] = 'An error occured during the representative/derivatives move. Please check the Piwigo and web server logs for details.';
$lang['MSG_SUCCESS'] = 'File successfully moved to ';
$lang['MSG_FILE_MOVE_ERR'] = 'An error occured during the file move. Please check the Piwigo and web server logs for details';
$lang['MSG_NO_DEST'] = 'No destination selected.';
$lang['DBG_SRC_ALBUM'] = 'source album: ';
$lang['DBG_SRC_FILE'] = 'source filename: ';
$lang['DBG_SRC_DIR'] = 'source directory: ';
$lang['DBG_SRC_PATH'] = 'source filepath: ';
$lang['DBG_DEST_ALBUM'] = 'destination album: ';
$lang['DBG_DEST_FILE'] = 'destination filename: ';
$lang['DBG_DEST_DIR'] = 'destination directory: ';
$lang['DBG_DEST_PATH'] = 'destination filepath: ';


?>
18 changes: 14 additions & 4 deletions main.inc.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
Plugin Name: Physical Photo Move
Version: 0.6
Version: 0.7
Description: Move a photo (the actual file) from one physical album to another, preserving all metadata.
Plugin URI: http://piwigo.org/ext/extension_view.php?eid=859
Author: windracer
Expand All @@ -15,12 +15,15 @@

define('PPM_PATH', PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');

// add ppm tab to items in physical albums
add_event_handler('tabsheet_before_select','ppm_add_tab', 50, 2);

// add language/translation support
add_event_handler('loading_lang', 'ppm_loading_lang');


function ppm_add_tab($sheets, $id)
{
load_language('plugin.lang', PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');

if ($id == 'photo')
{
// only add tab for "physical" photos (FTP sync, not uploaded)
Expand All @@ -29,11 +32,18 @@ function ppm_add_tab($sheets, $id)
if (!pwg_db_num_rows($result)) return $sheets;

$sheets['ppm'] = array(
'caption' => l10n('Move'),
'caption' => l10n('MOVE_BUTTON'),
'url' => get_root_url().'admin.php?page=plugin-physical_photo_move-'.$_GET['image_id'],
);
}

return $sheets;
}


function ppm_loading_lang()
{
load_language('plugin.lang', PPM_PATH);
}

?>

0 comments on commit 9779946

Please sign in to comment.