EddyVerbruggen / nativescript-localize

Internationalization plugin for NativeScript using native capabilities of each platform
MIT License
79 stars 31 forks source link

Doc needs info about how to translate using a TypeScript files and i18n files #36

Closed francisrod01 closed 6 years ago

francisrod01 commented 6 years ago

I think the doc needs more info about how to translate using a TypeScript like Android does.

Android uses XML resources:

<string name="table">Mesa %1$s</string>

<plurals name="fragment_sale_show_people_count">
  <item quantity="one">%d persona</item>
  <item quantity="other">%d personas</item>
</plurals>

And Java get it and parse it too:

Resources r = getResources();

// ....

String tableNumberText = r.getString(R.string.table);
TextView viewTableNumber = mView.findViewById(R.id.table_number_display);
viewTableNumber.setText(String.format(tableNumberText, table.getNumber()));

int peopleCount = sale.getPeople();
String peopleCountText = r.getQuantityString(R.plurals.fragment_sale_show_people_count, peopleCount, peopleCount);
TextView viewPeopleCount = mView.findViewById(R.id.num_people_display);
viewPeopleCount.setText(peopleCountText);

I think we should use a TypeScript to get it as XML/JSON as well.

lfabreges commented 6 years ago

I don't understand... are you talking about adding plurals support ?

francisrod01 commented 6 years ago

I think we should be use TypeScript component (in this moment we use angular directive tags (translate in html template)

I think we should be use plurals support as well.

lfabreges commented 6 years ago

I don't think I get it. You can use the L pipe or the localize function to translate text. If needed, you can directly access Android or iOS API to fit your needs.

I won't add plurals support myself, but I'd gladly accept a PR, it'll have to support both Android and iOS.