| 1 | /*
|
|---|
| 2 | * This file is part of EC-CUBE
|
|---|
| 3 | *
|
|---|
| 4 | * Copyright(c) 2000-2012 LOCKON CO.,LTD. All Rights Reserved.
|
|---|
| 5 | *
|
|---|
| 6 | * http://www.lockon.co.jp/
|
|---|
| 7 | *
|
|---|
| 8 | * This program is free software; you can redistribute it and/or
|
|---|
| 9 | * modify it under the terms of the GNU General Public License
|
|---|
| 10 | * as published by the Free Software Foundation; either version 2
|
|---|
| 11 | * of the License, or (at your option) any later version.
|
|---|
| 12 | *
|
|---|
| 13 | * This program is distributed in the hope that it will be useful,
|
|---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 16 | * GNU General Public License for more details.
|
|---|
| 17 | *
|
|---|
| 18 | * You should have received a copy of the GNU General Public License
|
|---|
| 19 | * along with this program; if not, write to the Free Software
|
|---|
| 20 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|---|
| 21 | */
|
|---|
| 22 |
|
|---|
| 23 | function fnT() {
|
|---|
| 24 | var msgid = '';
|
|---|
| 25 |
|
|---|
| 26 | if (arguments.length == 0) {
|
|---|
| 27 | throw new Error('invalid arguments.');
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | // message id only.
|
|---|
| 31 | if (arguments.length == 1) {
|
|---|
| 32 | msgid = arguments[0];
|
|---|
| 33 | if (cube_locale_messages[msgid]) {
|
|---|
| 34 | return cube_locale_messages[msgid];
|
|---|
| 35 | }
|
|---|
| 36 | return msgid;
|
|---|
| 37 | }
|
|---|
| 38 |
|
|---|
| 39 | // formated message
|
|---|
| 40 | if (arguments.length > 1) {
|
|---|
| 41 | msgid = arguments[0];
|
|---|
| 42 | if (cube_locale_messages[msgid]) {
|
|---|
| 43 | var message = cube_locale_messages[msgid];
|
|---|
| 44 | for (var i = 1; i < arguments.length; i++) {
|
|---|
| 45 | var reg = new RegExp("\\{" + (i - 1) + "\\}", "g");
|
|---|
| 46 | if (arguments[i] == null) {
|
|---|
| 47 | message = message.replace(reg, "null");
|
|---|
| 48 | } else {
|
|---|
| 49 | try {
|
|---|
| 50 | message = message.replace(reg, arguments[i].toString());
|
|---|
| 51 | } catch (e) {
|
|---|
| 52 | message = message.replace(reg, "[object]");
|
|---|
| 53 | }
|
|---|
| 54 | }
|
|---|
| 55 | }
|
|---|
| 56 | return message;
|
|---|
| 57 | }
|
|---|
| 58 | return msgid;
|
|---|
| 59 | }
|
|---|
| 60 | return msgid;
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|