/**
 * Copyright (c) 2011 ZhongLigang. All Rights Reserved
 * $Id$ 
 * 
 * @file js/en.js
 * @author zhongligang <ZhongLigang@gmail.com>
 * @date 2011-11-12 23:04:44
 */

// transilations
var L = {
    'Sure to delete this comment?'  : 'Sure to delete this comment?',
    'You should login first'        : 'You should login first',
    ' You like this'                : ' You like this',
    ' You and 1 other person like this' : ' You and 1 other person like this',
    ' You and #{0} others like this' : ' You and #{0} others like this',
    'Following'                     : 'Following',
    'Follow'                        : 'Follow',
    'ID or Email'                   : 'ID or Email',
    'password'                      : 'password',
    'Sign In'                       : 'Sign In',
    'Forgot Password?'              : 'Forgot Password?',
    'Remember Me'                   : 'Remember Me',
    'Not a member?'                 : 'Not a member?',
    'create an account for free and join the fun today' : 'create an account for free and join the fun today',
    'Get Started'                   : 'Get Started',
    'Unknown error, please try again later' : 'Unknown error, please try again later',
    'Country'                       : 'Country',
    'State/Province'                : 'State/Province',
    'City'                          : 'City',
    'I want to Send Flat Stanley'   : 'I want to Send Flat Stanley',
    'I want to Receive Flat Stanley' : 'I want to Receive Flat Stanley',
    'Write a post'                  : 'Write a post',
    'Your Email (Your email will NOT be displayed, but you will receive an email if other users reply your post on the Bulletin Board)' : 'Your Email (Your email will NOT be displayed, but you will receive an email if other users reply your post on the Bulletin Board)',
    'Post To Bulletin Board'        : 'Post To Bulletin Board',
    'Please select country first'   : 'Please select country first',
    'Please select state first'     : 'Please select state first',
    'Contact user by email'         : 'Contact user by email',
    'Please input country'          : 'Please input country',
    'Please input state/region'     : 'Please input state/region',
    'Please input the post'         : 'Please input the post',
    'Please input a valid email address' : 'Please input a valid email address',
    'Icon Send'                     : 'Send',
    'Icon Receive'                  : 'Receive',
    'Delete'                        : 'Delete',
    'delete fail'                   : 'delete fail',
    'Fail to get data!'             : 'Fail to get data!',
    'Your email address'            : 'Your email address',
    'Send'                          : 'Send',
    'Last Action: '                 : 'Last Action: ',
    'Posted: '                      : 'Posted: ',
    'Dear #{0},'                    : 'Dear #{0},',
    'please input post content'     : 'please input post content',
    'Email has been sent'           : 'Email has been sent',
    'Post To Bulletin Board'        : 'Post To Bulletin Board',
    'Icon S'                        : 'S',
    'Icon R'                        : 'R',
    'Welcome to Flatter World!'     : 'Welcome to Flatter World!',
    'Unable to register, please try again later' : 'Unable to register, please try again later',
    'Unable to save your profile, please try again later' : 'Unable to save your profile, please try again later',
    'Your account info has been successfully saved' : 'Your account info has been successfully saved',
    'Share Photo'                   : 'Share Photo',
    'Photo position'                : 'Photo position',
    'Upload From Computer'          : 'Upload From Computer',
    'Network Error, please try again.' : 'Network Error, please try again.',
    'Fail to upload, please try again.' : 'Fail to upload, please try again.',
    'Max file size exceeded.'       : 'Max file size exceeded.',
    'Upload was stopped.'           : 'Upload was stopped.',
    'Uploading. Please wait'        : 'Uploading. Please wait',
    'File too large'                : 'File too large',
    'File is empty'                 : 'File is empty',
    'Invalid file type'             : 'Invalid file type',
    'Unknown error'                 : 'Unknown error',
    'Write a Story'                 : 'Write a Story',
    'Please write a description of this photo' : 'Please write a description of this photo',
    'Network Error'                 : 'Network Error',
    'Unable to login, please try again later.' : 'Unable to login, please try again later.'
};

/**
 * Usage:
 *      __('this #{0} #{1} sample', ['this', 'is']);
 *      __('this #{0} #{1} sample', 'this', 'is');
 *      __('this #{p1} #{p2} sample', {p1:'this', p2:'is'});
 *
 */
function __(source, opts) {
    source = String(L[source] || source);
    var data = Array.prototype.slice.call(arguments,1), toString = Object.prototype.toString;

    if(data.length){
	    data = data.length == 1
            ? (opts !== null && (/\[object Array\]|\[object Object\]/.test(toString.call(opts))) ? opts : data) 
	    	: data;
    	return source.replace(/#\{(.+?)\}/g, function (match, key){
	    	var replacer = data[key];
	    	if('[object Function]' == toString.call(replacer)){
	    		replacer = replacer(key);
	    	}
	    	return ('undefined' == typeof replacer ? '' : replacer);
    	});
    }
    return source;
}
/* vim: set ts=4 sw=4 sts=4 tw=100 et: */

