p-calendar i18n does not work (version 11)

UI Components for Angular
Post Reply
User avatar
acsiseci
Posts: 3
Joined: 27 Sep 2020, 12:03
Contact:

21 Feb 2021, 23:46

Hi
I added files to the directory (i18n >> tr.json,en.json) , but month names change , day names not changing .What do you think is the cause of the problem ?

en.json

Code: Select all

"primeng": {
    "dayNamesMin": ["Su","Mo","Tu","We","Th","Fr","Sa"],
    "monthNames": ["January","February","March","April","May","June","July","August","September","October","November","December"],
  }
  
tr.json

Code: Select all

"primeng": {
    "dayNamesMin": ["Pz","Pt","Sl","Çr","Pr","Cm","Ct"],
    "monthNames": ["Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"],
  }
  
Language selection button onChange Function

Code: Select all

changeLanguage(lang) {
        this.translate.use(lang.value);
        this.translate.get('primeng').subscribe(res => this.config.setTranslation(res));
    }
    

mczudek00
Posts: 1
Joined: 30 Apr 2020, 19:06

06 May 2021, 17:31

Hi,

I have the same issue, and I was not able to solve it yet.

Any advice would be appreciated

Thank you

PhilHuhn
Posts: 177
Joined: 19 Sep 2018, 02:52
Location: Ann Arbor, Michigan USA
Contact:

08 May 2021, 13:09

Hey:

In my app.component:

Code: Select all

import { PrimeNGConfig } from 'primeng/api';

	...

	constructor(
		public _config: PrimeNGConfig
	) {
		this.codeName = 'demo-mg.app.component';
	}
	/*
	** Configure the locale and grab the locale
	** from the environment.
	*/
	ngOnInit() {
		this.setLocale( this._config, environment.locale );
	}
	/*
	** Globally configure the locale (i18n).
	*/
	setLocale( config: PrimeNGConfig, locale: string ): void {
		switch( locale.toLowerCase( ) ) {
			case 'en': {
				// already english
				const dow: string[] = config.getTranslation( 'dayNames' );
				if( dow[0] !== 'Sunday' ) {
					const msg: string = 'Default locale not EN.';
					console.error( `${this.codeName}: ${msg}` );
				} else {
					console.log( `${this.codeName}: Using locale: '${locale}'` );
				}
				break;
			}
			case 'es': {
				config.setTranslation( {
					startsWith: 'Comienza con',
					contains: 'Contiene',
					notContains: 'No contiene',
					endsWith: 'Termina con',
					equals: 'Igual',
					notEquals: 'No es igual',
					noFilter: 'Sin filtro',
					lt: 'Menos que',
					lte: 'Menos que o igual a',
					gt: 'Mas grande que',
					gte: 'Mayor qué o igual a',
					is: 'Es',
					isNot: 'No es',
					before: 'Before',
					after: 'After',
					apply: 'Aplicar',
					matchAll: 'Coincidir con todos',
					matchAny: 'Coincidir con cualquiera',
					addRule: 'Agregar regla',
					removeRule: 'Eliminar regla',
					accept: 'Si',
					reject: 'No',
					choose: 'Escoger',
					upload: 'Subir',
					cancel: 'Cancelar',
					dayNames: [ 'Domingo','Lunes','Martes','Miércoles','Jueves','Viernes','Sábado' ],
					dayNamesShort: [ 'dom','lun','mar','mié','jue','vie','sáb' ],
					dayNamesMin: [ 'D','L','M','X','J','V','S' ],
					monthNames: [ 'Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre' ],
					monthNamesShort: [ 'Ene','Feb','Mar','Abr','May','Jun','Jul','Ago','Sep','Oct','Nov','Dic' ],
					today: 'Hoy',
					clear: 'Limpiar',
					weekHeader: 'Sm'
				});
				break;
			}
			case 'de': {
				config.setTranslation( {
					startsWith: 'Beginnt mit',
					contains: 'Enthält',
					notContains: 'Enthält nicht',
					endsWith: 'Endet mit',
					equals: 'Gleich',
					notEquals: 'Kein Filter',
					noFilter: 'Kein Filter',
					lt: 'Weniger als',
					lte: 'Weniger als oder gleich',
					gt: 'Größer als',
					gte: 'Größer als oder gleich wie',
					is: 'Ist',
					isNot: 'Ist nicht',
					before: 'Vor',
					after: 'Nach dem',
					apply: 'Anwenden',
					matchAll: 'Alle zusammenbringen',
					matchAny: 'Passen Sie zu einem',
					addRule: 'Regel hinzufügen',
					removeRule: 'Regel entfernen',
					accept: 'Ja',
					reject: 'Nein',
					choose: 'Wählen',
					upload: 'Hochladen',
					cancel: 'Stornieren',
					dayNames: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samastag'],
					dayNamesShort: ['Son', 'Mon', 'Die', 'Mit', 'Don', 'Fre', 'Sam'],
					dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
					monthNames: [ 'Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember' ],
					monthNamesShort: [ 'Jan', 'Feb', 'Mär', 'Apr', 'Mai', 'Jun','Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez' ],
					today: 'Heute',
					clear: 'Löschen',
					weekHeader: 'Wo'
				});
				break;
			}
			default: {
				const msg: string = `Locale: '${locale}' not available.`;
				console.error( `${this.codeName}: ${msg}` );
				break;
			}
		}
	}
My environment is as follows:

Code: Select all

export const environment = {
	production: false,
	logLevel: 4,
	locale: 'en',
	base_Url: 'http://localhost:9112/api/'
};
I am not entirely sure about the translations.

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 7 guests