From 280daa7f3f858ecfef9c91ffd5dea1007f021048 Mon Sep 17 00:00:00 2001
From: rsanchez <rsanchez@curisit.net>
Date: Sun, 19 Mar 2017 11:29:37 +0000
Subject: [PATCH] #3527 fix - Added applications and some minor refactoring
---
securis/src/main/webapp/src/app/common/i18n.ts | 25 +++++++++++++++++++++----
1 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/securis/src/main/webapp/src/app/common/i18n.ts b/securis/src/main/webapp/src/app/common/i18n.ts
index 148f562..7e71f18 100644
--- a/securis/src/main/webapp/src/app/common/i18n.ts
+++ b/securis/src/main/webapp/src/app/common/i18n.ts
@@ -2,6 +2,18 @@
import { ModuleWithProviders, NgModule, Inject, Injectable, Directive, ElementRef, HostListener, Input, Renderer } from '@angular/core';
declare var navigator:any;
+declare global {
+ interface String {
+ capitalize(): string;
+ cap(): string;
+ }
+}
+
+String.prototype.capitalize = function() {
+ return this[0].toUpperCase() + this.slice(1);
+}
+String.prototype.cap = String.prototype.capitalize;
+
// Use as reference: https://github.com/ngx-translate/core/tree/master/src
@Injectable()
export class LocaleService {
@@ -50,9 +62,11 @@
* It works similar to MessageFormat in Java
*/
_format(str: string, ...params: string[]) {
-
- return str.replace(/\{(\d+)\}/g, function(match, index) {
- return params[index];
+ var ocur = 0;
+ return str.replace(/\{(\d*)\}/g, function(match, index) {
+ var idx = index === '' ? ocur : +index;
+ ocur += 1;
+ return params[idx];
});
};
@@ -98,9 +112,10 @@
}
// Enviar evento cuando el idioma cambia al $rootScope
- if (arguments.length === 1) return trans_msg;
+ if (params.length === 0) return trans_msg;
return this._format(trans_msg, ...params);
}
+
}
@@ -134,3 +149,5 @@
}
+
+
--
Gitblit v1.3.2