Generator-jhipster: Unable to using other languages except english for jhi-item-count.component.ts labels.

Created on 10 May 2017  Â·  10Comments  Â·  Source: jhipster/generator-jhipster

Overview of the issue

Jhi-item-count component of ng-jhipster library contains hardcoded (english) values of labels - Showing, of , items

Motivation for or Use Case

Simple motivation - use another languages for a labels.

Reproduce the error

Generate a project with pagination option.

JHipster Version(s)

4.4.1

ng-jhipster

Most helpful comment

The tricky part is, that we need a way to generate an application, without i18n support. So either we keep the old, non-i18n component in ng-jhipster, and in generation-time we pick the appropriate one, or the component needs to be enhanced to support the two way of operations

All 10 comments

I'm on it :)

_EDIT_ : We have to put new values in each i18n/*/global.json :

Showing {{((page - 1) * itemsPerPage) == 0 ? 1 : ((page - 1) * itemsPerPage + 1)}} -
{{(page * itemsPerPage) < total ? (page * itemsPerPage) : total}}
of {{total}} items.

Are you OK with a new key like global.item-count ?

I'll do 2 PR separately.
One in the generator-jhipster (a new key in all i18n files)
and another in ng-jhipster (the item-count component).

I block slightly on a test issue in ng-jhipster, but the fix comes up ;)

Concerning the new key, I only managed to translate (more or less correctly) :

  • pt-br
  • pt
  • fr
  • de
  • sv
  • cs
  • da
  • el
  • ca
  • it
  • es
  • nl
  • ro
  • gl

(Thanks Google Translate !)

The tricky part is, that we need a way to generate an application, without i18n support. So either we keep the old, non-i18n component in ng-jhipster, and in generation-time we pick the appropriate one, or the component needs to be enhanced to support the two way of operations

We can use the conditions passed during the ng-jhipster module
initialization to handle i18n and non i18n. Like how its done for the alert
componenets

Thanks & Regards,
Deepu

On Wed, May 17, 2017 at 9:00 AM, Zsombor notifications@github.com wrote:

The tricky part is, that we need a way to generate an application, without
i18n support. So either we keep the old, non-i18n component in ng-jhipster,
and in generation-time we pick the appropriate one, or the component needs
to be enhanced to support the two way of operations

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/jhipster/generator-jhipster/issues/5739#issuecomment-302003607,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABDlFxj4B4RXFoFNQgujg4uD99_aLOgAks5r6psMgaJpZM4NWrmA
.

I'm actually coding a way using both a @HostBinding and an @Input, on the jhi-item component.
Something like this (can maybe change a little) :

@Input() i18nSupported: boolean;

@HostBinding('attr.jhiTranslate') jhiTranslate: string = !this.i18nSupported ? null : 'global.item-count';

@HostBinding('attr.translateValues') translateValues: string = !this.i18nSupported ? null :
        '{first: \'+{{((page - 1) * itemsPerPage) == 0 ? 1 : ((page - 1) * itemsPerPage + 1)}}\',' +
        'second: \'{{(page * itemsPerPage) < total ? (page * itemsPerPage) : total}}\',' +
        'total: \'{{total}}\'}';

In this way, when initialization, we only have to add a i18nSupported="true" to the jhi-item directive, and the translation attribute will be added.

What do you prefer ?

Can you look at how its handled in aler components i would like behaviour
to be same on all

On Wed, 17 May 2017, 10:55 am Julien Margarido, notifications@github.com
wrote:

I'm actually coding a way using both a @HostBinding
https://github.com/hostbinding and an @input https://github.com/input,
on the jhi-item component.
Something like this (can maybe change a little) :

@Input() i18nSupported: boolean;

@HostBinding('attr.jhiTranslate') jhiTranslate: string = !this.i18nSupported ? null : 'global.item-count';

@HostBinding('attr.translateValues') translateValues: string = !this.i18nSupported ? null :
'{first: '+{{((page - 1) * itemsPerPage) == 0 ? 1 : ((page - 1) * itemsPerPage + 1)}}',' +
'second: '{{(page * itemsPerPage) < total ? (page * itemsPerPage) : total}}',' +
'total: '{{total}}'}';

In this way, when initialization, we only have to add a
i18nSupported="true" to the jhi-item directive, an the translation
attribute will be added.

What do you prefer ?

—
You are receiving this because you commented.

Reply to this email directly, view it on GitHub
https://github.com/jhipster/generator-jhipster/issues/5739#issuecomment-302028646,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABDlF_n2Q6pTuBoWLXUVsyii_tHKGwJuks5r6rYZgaJpZM4NWrmA
.

The _alert service_ is instantiated like this (in the generator) :
AlertService(sanitizer, isToast<% if (enableTranslation) { %>, translateService<% } %>);
and only use the _TranslateService_ here (alert.service.ts, line 105) :
alertOptions.msg = this.translateService.instant(alertOptions.msg, alertOptions.params);

capture d ecran de 2017-05-18 09-54-10

While the _jhi-item-count_ component is used in HTML only as a directive :
<jhi-item-count [page]="page" [total]="queryCount" [itemsPerPage]="itemsPerPage"></jhi-item-count>

Since we can not use the same way the _Alert service_ and the _jhi-item-count component_, I propose to use what @deepu105 had indicated, concerning the i18n conditions.

In ng-jhipster, by calling new ModuleConfig().i18nEnabled, the jhi-item-count component can know if it should leave the default template, or if it should add the "jhiTranslate" and "translateValues" attributes (see in jhi-item-count.component.ts).

As a result, no modification needed in the generator, just a few lines (which I have already coded) on ng-jhipster, and some minor modifications of the tests.

(and of course, there is no longer need what I suggested yesterday, concerning a new @Input "i18nSupported" or @HostBindings).

Ok

On Thu, 18 May 2017, 11:55 am Julien Margarido, notifications@github.com
wrote:

Since we can not use the same way the Alert service and the jhi-item-count
component
, I propose to use what @deepu105 https://github.com/deepu105
had indicated, concerning the 18n conditions.

In ng-jhipster, by calling new ModuleConfig().i18nEnabled, the
jhi-item-count component can know if it should leave the default template,
or if it should add the "jhiTranslate" and "translateValues" attributes
(see in jhi-item-count.component.ts).

As a result, no modification needed in the generator, just a few lines
(which I have already coded) on ng-jhipster, and some minor modifications
of the tests.

(and of course, there is no longer need what I suggested yesterday,
concerning a new @input https://github.com/input "i18nSupported" or
@hostbindings).

—
You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
https://github.com/jhipster/generator-jhipster/issues/5739#issuecomment-302357908,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABDlF-gTOkvM2_kUUdRPK5g33tPZ0fLiks5r7BV4gaJpZM4NWrmA
.

Can be closed after the jhipster/ng-jhipster#35 merge.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DanielFran picture DanielFran  Â·  3Comments

tomj0101 picture tomj0101  Â·  3Comments

frantzynicolas picture frantzynicolas  Â·  3Comments

RizziCR picture RizziCR  Â·  3Comments

pascalgrimaud picture pascalgrimaud  Â·  3Comments