Added localization.
This commit is contained in:
parent
e54abe08ca
commit
e4646734f2
14 changed files with 211 additions and 73 deletions
|
@ -1,4 +1,4 @@
|
|||
# h5ai v0.5.3   ·   a beautified Apache index
|
||||
# h5ai v0.6   ·   a beautified Apache index
|
||||
|
||||
|
||||
## Screenshots
|
||||
|
@ -47,6 +47,13 @@ please respect their rights.
|
|||
|
||||
## Changelog
|
||||
|
||||
### v0.6
|
||||
*2011-07-05*
|
||||
|
||||
* refactored js
|
||||
* added localization, see options.js
|
||||
|
||||
|
||||
### v0.5.3
|
||||
*2011-07-04*
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ custom = true
|
|||
|
||||
# project
|
||||
project.name = h5ai
|
||||
project.version = 0.5.3
|
||||
project.version = 0.6
|
||||
|
||||
|
||||
# src
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
}
|
||||
.label {
|
||||
display: block;
|
||||
margin: 0 220px 0 24px;
|
||||
margin: 0 270px 0 24px;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-align: left;
|
||||
|
@ -83,10 +83,10 @@
|
|||
}
|
||||
.date {
|
||||
position: absolute;
|
||||
right: 70px;
|
||||
right: 100px;
|
||||
top: 0;
|
||||
text-align: right;
|
||||
width: 140px;
|
||||
width: 160px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.size {
|
||||
|
@ -94,7 +94,7 @@
|
|||
right: 0;
|
||||
top: 0;
|
||||
text-align: right;
|
||||
width: 50px;
|
||||
width: 80px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<img class="techclass" src="/h5ai/images/html5-css3.png" alt="html5-css3" />
|
||||
</a>
|
||||
<a href="http://larsjung.de/h5ai" target="_blank" title="h5ai %BUILD_VERSION%">h5ai</a>
|
||||
using
|
||||
<span class="l10n-footerUsing">using</span>
|
||||
<a href="http://tiheum.deviantart.com/art/Faenza-Icons-173323228" target="_blank" title="icon theme for Gnome">Faenza icons</a>
|
||||
</footer>
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
|
||||
|
|
|
@ -16,9 +16,15 @@
|
|||
<nav>
|
||||
<span class="jsDisabledFallback">Directory index · JavaScript is disabled</span>
|
||||
<ul>
|
||||
<li id="domain" class="crumb"><a href="/"><img src="/h5ai/images/home.png" alt="domain" /><span>domain</span></a></li>
|
||||
<li id="viewicons" class="view"><a href="#"><img src="/h5ai/images/view-icons.png" alt="view-icons" />icons</a></li>
|
||||
<li id="viewdetails" class="view" ><a href="#"><img src="/h5ai/images/view-details.png" alt="view-details" />details</a></li>
|
||||
<li id="domain" class="crumb">
|
||||
<a href="/"><img src="/h5ai/images/home.png" alt="domain" /><span>domain</span></a>
|
||||
</li>
|
||||
<li id="viewicons" class="view">
|
||||
<a href="#"><img src="/h5ai/images/view-icons.png" alt="view-icons" /><span class="l10n-viewIcons">icons</span></a>
|
||||
</li>
|
||||
<li id="viewdetails" class="view" >
|
||||
<a href="#"><img src="/h5ai/images/view-details.png" alt="view-details" /><span class="l10n-viewDetails">details</span></a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="clearfix"></div>
|
||||
</nav>
|
||||
|
|
|
@ -26,7 +26,9 @@ var H5ai = function ( options ) {
|
|||
viewmodes: [ "details", "icons" ],
|
||||
showTree: false,
|
||||
folderStatus: {
|
||||
}
|
||||
},
|
||||
lang: undefined,
|
||||
useBrowserLang: true
|
||||
};
|
||||
this.config = $.extend( {}, defaults, options );
|
||||
|
||||
|
@ -65,6 +67,7 @@ var H5ai = function ( options ) {
|
|||
this.initBreadcrumb();
|
||||
this.initViews();
|
||||
this.customize();
|
||||
this.localize( h5aiLangs, this.config.lang, this.config.useBrowserLang );
|
||||
};
|
||||
|
||||
|
||||
|
@ -202,9 +205,9 @@ var H5ai = function ( options ) {
|
|||
var $label = $( "th.name a" );
|
||||
var $date = $( "th.date a" );
|
||||
var $size = $( "th.size a" );
|
||||
$( "<a class='label' href='" + $label.attr( "href" ) + "'>" + $label.text() + "</a>" ).appendTo( $li );
|
||||
$( "<a class='date' href='" + $date.attr( "href" ) + "'>" + $date.text() + "</a>" ).appendTo( $li );
|
||||
$( "<a class='size' href='" + $size.attr( "href" ) + "'>" + $size.text() + "</a>" ).appendTo( $li );
|
||||
$( "<a class='label' href='" + $label.attr( "href" ) + "'><span class='l10n-columnName'>" + $label.text() + "</span></a>" ).appendTo( $li );
|
||||
$( "<a class='date' href='" + $date.attr( "href" ) + "'><span class='l10n-columnLastModified'>" + $date.text() + "</span></a>" ).appendTo( $li );
|
||||
$( "<a class='size' href='" + $size.attr( "href" ) + "'><span class='l10n-columnSize'>" + $size.text() + "</span></a>" ).appendTo( $li );
|
||||
|
||||
// header sort icons
|
||||
var order = document.location.search;
|
||||
|
@ -265,6 +268,7 @@ var H5ai = function ( options ) {
|
|||
if ( $entries.size() > 0 ) {
|
||||
$entry0 = $( $entries.get(0) );
|
||||
if ( $entry0.find( ".label" ).text() === "Parent Directory" ) {
|
||||
$entry0.find( ".label" ).addClass( "l10n-parentDirectory" );
|
||||
$entry0.addClass( "parentfolder" );
|
||||
};
|
||||
};
|
||||
|
@ -329,4 +333,32 @@ var H5ai = function ( options ) {
|
|||
}
|
||||
} );
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*******************************
|
||||
* localization
|
||||
*******************************/
|
||||
|
||||
this.localize = function ( data, lang, useBrowserLang ) {
|
||||
|
||||
if ( useBrowserLang === true ) {
|
||||
var browserLang = navigator.language;
|
||||
if ( data[ browserLang ] !== undefined ) {
|
||||
lang = browserLang;
|
||||
} else if ( browserLang.length > 2 && data[ browserLang.substr( 0, 2 ) ] !== undefined ) {
|
||||
lang = browserLang.substr( 0, 2 );
|
||||
};
|
||||
if ( lang === "en" ) {
|
||||
lang = undefined;
|
||||
};
|
||||
};
|
||||
|
||||
if ( data[ lang ] !== undefined ) {
|
||||
var selected = data[ lang ];
|
||||
for ( key in selected ) {
|
||||
$( ".l10n-" + key ).text( selected[key] );
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -159,32 +159,32 @@ var Tree = function ( utils, h5ai ) {
|
|||
console.log( "checkPathname", pathname, status );
|
||||
if ( status !== 0 ) {
|
||||
callback( status );
|
||||
} else {
|
||||
$.ajax( {
|
||||
url: pathname,
|
||||
type: "GET",
|
||||
dataType: "html",
|
||||
error: function ( xhr ) {
|
||||
// since it was checked before this should never happen
|
||||
callback( xhr.status );
|
||||
},
|
||||
success: function ( html, status, xhr ) {
|
||||
if ( !contentTypeRegEx.test( xhr.getResponseHeader( "Content-Type" ) ) ) {
|
||||
// since it was checked before this should never happen
|
||||
callback( xhr.status );
|
||||
} else {
|
||||
var entries = [];
|
||||
$( html ).find( "#table table td" ).closest( "tr" ).each( function () {
|
||||
var entry = new File( utils, pathname, this );
|
||||
if ( !entry.isParentFolder || includeParent ) {
|
||||
entries.push( entry );
|
||||
};
|
||||
} );
|
||||
callback( entries );
|
||||
};
|
||||
}
|
||||
} );
|
||||
return;
|
||||
};
|
||||
|
||||
$.ajax( {
|
||||
url: pathname,
|
||||
type: "GET",
|
||||
dataType: "html",
|
||||
error: function ( xhr ) {
|
||||
callback( xhr.status ); // since it was checked before this should never happen
|
||||
},
|
||||
success: function ( html, status, xhr ) {
|
||||
if ( !contentTypeRegEx.test( xhr.getResponseHeader( "Content-Type" ) ) ) {
|
||||
callback( xhr.status ); // since it was checked before this should never happen
|
||||
return;
|
||||
};
|
||||
|
||||
var entries = [];
|
||||
$( html ).find( "#table table td" ).closest( "tr" ).each( function () {
|
||||
var entry = new File( utils, pathname, this );
|
||||
if ( !entry.isParentFolder || includeParent ) {
|
||||
entries.push( entry );
|
||||
};
|
||||
} );
|
||||
callback( entries );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
};
|
||||
|
||||
|
@ -195,24 +195,25 @@ var Tree = function ( utils, h5ai ) {
|
|||
|
||||
if ( h5ai.config.folderStatus[ pathname ] !== undefined ) {
|
||||
callback( h5ai.config.folderStatus[ pathname ] );
|
||||
} else {
|
||||
if ( pathnameCache[ pathname ] !== undefined ) {
|
||||
callback( pathnameCache[ pathname ] );
|
||||
} else {
|
||||
$.ajax( {
|
||||
url: pathname,
|
||||
type: "HEAD",
|
||||
complete: function ( xhr ) {
|
||||
if ( xhr.status === 200 && contentTypeRegEx.test( xhr.getResponseHeader( "Content-Type" ) ) ) {
|
||||
pathnameCache[ pathname ] = 0;
|
||||
callback( 0 );
|
||||
} else {
|
||||
pathnameCache[ pathname ] = xhr.status;
|
||||
callback( xhr.status );
|
||||
};
|
||||
}
|
||||
} );
|
||||
};
|
||||
return;
|
||||
};
|
||||
|
||||
if ( pathnameCache[ pathname ] !== undefined ) {
|
||||
callback( pathnameCache[ pathname ] );
|
||||
return;
|
||||
};
|
||||
|
||||
$.ajax( {
|
||||
url: pathname,
|
||||
type: "HEAD",
|
||||
complete: function ( xhr ) {
|
||||
var status = xhr.status;
|
||||
if ( xhr.status === 200 && contentTypeRegEx.test( xhr.getResponseHeader( "Content-Type" ) ) ) {
|
||||
status = 0;
|
||||
};
|
||||
pathnameCache[ pathname ] = status;
|
||||
callback( status );
|
||||
}
|
||||
} );
|
||||
};
|
||||
};
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
h5aiOptions = {
|
||||
|
||||
/*
|
||||
* An array of view modes the user may chose from. Currently there
|
||||
* An array of view modes the user may choose from. Currently there
|
||||
* are two possible values: "details" and "icons". The first value
|
||||
* indicates the default view mode. If only one value is given the
|
||||
* view mode is fixed and the selector buttons are hidden.
|
||||
|
@ -15,9 +15,10 @@ h5aiOptions = {
|
|||
* Show a folder tree, boolean.
|
||||
* Note that this tree might have side effects as it sends HEAD requests
|
||||
* to the folders, and therefore will invoke index.php scripts. Use
|
||||
* folderStatus below to avoid such requests.
|
||||
* folderStatus below to avoid such requests.
|
||||
* It might also affect performance significantly.
|
||||
*/
|
||||
showTree: true,
|
||||
showTree: false,
|
||||
|
||||
/*
|
||||
* Associative array of folders and their HTTP status codes to
|
||||
|
@ -34,6 +35,48 @@ h5aiOptions = {
|
|||
* for example:
|
||||
* "/some/folder/": 200
|
||||
*/
|
||||
},
|
||||
|
||||
/*
|
||||
* Localization, for example "en", "de" etc. - see h5aiLangs below for
|
||||
* possible values. Adjust it to your needs. If lang is not found in
|
||||
* h5aiLangs the displayed labels stay unchanged.
|
||||
*/
|
||||
lang: undefined,
|
||||
|
||||
/*
|
||||
* Try to use browser language, falls back to previous specified lang.
|
||||
*/
|
||||
useBrowserLang: true
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Available translations.
|
||||
* "en" is just an example - see it as a reference. Those values
|
||||
* are "hardcoded" and will be displayed if all labels stay unchanged.
|
||||
*/
|
||||
h5aiLangs = {
|
||||
|
||||
"en": {
|
||||
viewDetails: "details",
|
||||
viewIcons: "icons",
|
||||
columnName: "Name",
|
||||
columnLastModified: "Last modified",
|
||||
columnSize: "Size",
|
||||
footerUsing: "using",
|
||||
parentDirectory: "Parent Directory"
|
||||
},
|
||||
|
||||
"de": {
|
||||
viewDetails: "Details",
|
||||
viewIcons: "Icons",
|
||||
columnName: "Name",
|
||||
columnLastModified: "Geändert",
|
||||
columnSize: "Größe",
|
||||
footerUsing: "nutzt",
|
||||
parentDirectory: "Übergeordnetes Verzeichnis"
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
################################
|
||||
# h5ai 0.5.3
|
||||
# h5ai 0.6
|
||||
# customized .htaccess
|
||||
################################
|
||||
|
||||
|
@ -56,7 +56,7 @@
|
|||
|
||||
IndexOrderDefault Ascending Name
|
||||
|
||||
IndexOptions Type=text/html;h5ai=0.5.3
|
||||
IndexOptions Type=text/html;h5ai=0.6
|
||||
IndexOptions Charset=UTF-8
|
||||
IndexOptions FancyIndexing
|
||||
IndexOptions HTMLTable
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -11,8 +11,8 @@
|
|||
<img class="techclass" src="/h5ai/images/html5-storage.png" alt="html5-storage" />
|
||||
<img class="techclass" src="/h5ai/images/html5-css3.png" alt="html5-css3" />
|
||||
</a>
|
||||
<a href="http://larsjung.de/h5ai" target="_blank" title="h5ai 0.5.3">h5ai</a>
|
||||
using
|
||||
<a href="http://larsjung.de/h5ai" target="_blank" title="h5ai 0.6">h5ai</a>
|
||||
<span class="l10n-footerUsing">using</span>
|
||||
<a href="http://tiheum.deviantart.com/art/Faenza-Icons-173323228" target="_blank" title="icon theme for Gnome">Faenza icons</a>
|
||||
</footer>
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Directory index · styled with h5ai</title>
|
||||
<meta name="h5ai-version" content="h5ai 0.5.3">
|
||||
<meta name="h5ai-version" content="h5ai 0.6">
|
||||
<meta name="description" content="Directory index styled with h5ai (http://larsjung.de/h5ai)">
|
||||
<meta name="keywords" content="directory, index, autoindex, h5ai">
|
||||
<link rel="shortcut icon" type="image/png" href="/h5ai/images/h5ai-16x16.png">
|
||||
|
@ -16,9 +16,15 @@
|
|||
<nav>
|
||||
<span class="jsDisabledFallback">Directory index · JavaScript is disabled</span>
|
||||
<ul>
|
||||
<li id="domain" class="crumb"><a href="/"><img src="/h5ai/images/home.png" alt="domain" /><span>domain</span></a></li>
|
||||
<li id="viewicons" class="view"><a href="#"><img src="/h5ai/images/view-icons.png" alt="view-icons" />icons</a></li>
|
||||
<li id="viewdetails" class="view" ><a href="#"><img src="/h5ai/images/view-details.png" alt="view-details" />details</a></li>
|
||||
<li id="domain" class="crumb">
|
||||
<a href="/"><img src="/h5ai/images/home.png" alt="domain" /><span>domain</span></a>
|
||||
</li>
|
||||
<li id="viewicons" class="view">
|
||||
<a href="#"><img src="/h5ai/images/view-icons.png" alt="view-icons" /><span class="l10n-viewIcons">icons</span></a>
|
||||
</li>
|
||||
<li id="viewdetails" class="view" >
|
||||
<a href="#"><img src="/h5ai/images/view-details.png" alt="view-details" /><span class="l10n-viewDetails">details</span></a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="clearfix"></div>
|
||||
</nav>
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -2,7 +2,7 @@
|
|||
h5aiOptions = {
|
||||
|
||||
/*
|
||||
* An array of view modes the user may chose from. Currently there
|
||||
* An array of view modes the user may choose from. Currently there
|
||||
* are two possible values: "details" and "icons". The first value
|
||||
* indicates the default view mode. If only one value is given the
|
||||
* view mode is fixed and the selector buttons are hidden.
|
||||
|
@ -15,9 +15,10 @@ h5aiOptions = {
|
|||
* Show a folder tree, boolean.
|
||||
* Note that this tree might have side effects as it sends HEAD requests
|
||||
* to the folders, and therefore will invoke index.php scripts. Use
|
||||
* folderStatus below to avoid such requests.
|
||||
* folderStatus below to avoid such requests.
|
||||
* It might also affect performance significantly.
|
||||
*/
|
||||
showTree: true,
|
||||
showTree: false,
|
||||
|
||||
/*
|
||||
* Associative array of folders and their HTTP status codes to
|
||||
|
@ -34,6 +35,48 @@ h5aiOptions = {
|
|||
* for example:
|
||||
* "/some/folder/": 200
|
||||
*/
|
||||
},
|
||||
|
||||
/*
|
||||
* Localization, for example "en", "de" etc. - see h5aiLangs below for
|
||||
* possible values. Adjust it to your needs. If lang is not found in
|
||||
* h5aiLangs the displayed labels stay unchanged.
|
||||
*/
|
||||
lang: undefined,
|
||||
|
||||
/*
|
||||
* Try to use browser language, falls back to previous specified lang.
|
||||
*/
|
||||
useBrowserLang: true
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Available translations.
|
||||
* "en" is just an example - see it as a reference. Those values
|
||||
* are "hardcoded" and will be displayed if all labels stay unchanged.
|
||||
*/
|
||||
h5aiLangs = {
|
||||
|
||||
"en": {
|
||||
viewDetails: "details",
|
||||
viewIcons: "icons",
|
||||
columnName: "Name",
|
||||
columnLastModified: "Last modified",
|
||||
columnSize: "Size",
|
||||
footerUsing: "using",
|
||||
parentDirectory: "Parent Directory"
|
||||
},
|
||||
|
||||
"de": {
|
||||
viewDetails: "Details",
|
||||
viewIcons: "Icons",
|
||||
columnName: "Name",
|
||||
columnLastModified: "Geändert",
|
||||
columnSize: "Größe",
|
||||
footerUsing: "nutzt",
|
||||
parentDirectory: "Übergeordnetes Verzeichnis"
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue