Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n: Apply translation scheme. #100

Merged
merged 3 commits into from
Feb 23, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions apps/search/src/assets/i18n/da.json

This file was deleted.

12 changes: 0 additions & 12 deletions apps/search/src/assets/i18n/de.json

This file was deleted.

43 changes: 22 additions & 21 deletions apps/search/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
{
"records": "records",
"recordViewable": "viewable",
"recordDownloadable": "downloadable",
"readMore": "Read more",
"search.loading": "Loading ...",
"dropFile": "drop file",
"Back": "Back",
"search.field.any.placeholder": "Search datasets, services and maps ...",
"search.field.sortBy": "Sort by",
"relevancy": "Relevancy",
"createDate": "New records",
"dateStamp": "Last updates",
"popularity": "Popularity",
"results.records.hits.found": "{hits, plural, =0{No documents match the specified search.} one{} other{{hits} records found.}}",
"results.records.hits.found=0.help": "Suggestions: <ul class='list-disc list-inside'><li>Try other words</li><li>Specify fewer words</li></ul>",
"results.layout.selectOne": "Results layout",
"facets.block.title.tag": "Keywords",
"availableInDownloadService": "Download",
"availableInViewService": "View",
"facets.block.title.OrgForResource": "Organisation",
"facets.block.title.availableInServices": "Available for",
"facets.block.title.cl_hierarchyLevel.key": "Resource type",
"facets.block.title.cl_status.key": "Status",
"facets.block.title.cl_maintenanceAndUpdateFrequency.key": "Update frequency",
"facets.block.title.cl_spatialRepresentationType.key": "Spatial representation",
"facets.block.title.cl_status.key": "Status",
"facets.block.title.creationYearForResource": "Creation year",
"facets.block.title.th_regions_tree.default": "Regions",
"facets.block.title.OrgForResource": "Organisation",
"facets.block.title.resolutionScaleDenominator": "Scale",
"facets.block.title.tag": "Keywords",
"facets.block.title.tag.default": "Tag",
"facets.block.title.availableInServices": "Available for"
"facets.block.title.th_regions_tree.default": "Regions",
"nav.back": "Back",
"record.action.download": "downloadable",
"record.action.view": "viewable",
"record.more.details": "Read more",
"records": "records",
"results.layout.selectOne": "Results layout",
"results.records.hits.found": "{hits, plural, =0{No documents match the specified search.} one{} other{{hits} records found.}}",
"results.records.hits.found=0.help": "Suggestions: <ul class='list-disc list-inside'><li>Try other words</li><li>Specify fewer words</li></ul>",
"results.sortBy.createDate": "New records",
"results.sortBy.dateStamp": "Last updates",
"results.sortBy.popularity": "Popularity",
"results.sortBy.relevancy": "Relevancy",
"search.field.any.placeholder": "Search datasets, services and maps ...",
"search.field.sortBy": "Sort by",
"search.loading": "Loading ..."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how did you change the order ? Did you use the npm script to extract the translations ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSON sort plugin.

  • Apply translation scheme to english translations
    What does it mean ?

We discussed to apply a common pattern/scheme to translation keys - like in
https://github.com/geonetwork/geonetwork-ui/blob/master/apps/datafeeder/src/assets/i18n/en.json or https://github.com/geonetwork/geonetwork-microservices/blob/main/modules/services/ogc-api-records/service/src/main/resources/messages/api.properties
no?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I was confused by the term "schema"

}
12 changes: 0 additions & 12 deletions apps/search/src/assets/i18n/fi.json

This file was deleted.

29 changes: 0 additions & 29 deletions apps/search/src/assets/i18n/fr.json

This file was deleted.

12 changes: 0 additions & 12 deletions apps/search/src/assets/i18n/nb.json

This file was deleted.

12 changes: 0 additions & 12 deletions apps/search/src/assets/i18n/nl.json

This file was deleted.

12 changes: 0 additions & 12 deletions apps/search/src/assets/i18n/sv.json

This file was deleted.

9 changes: 3 additions & 6 deletions libs/search/src/lib/sort-by/sort-by.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,22 @@ import { SearchState } from '../state/reducer'
import { getSearchSortBy } from '../state/selectors'
import { marker } from '@biesbjerg/ngx-translate-extract-marker'

marker('last changed')
marker('popularity')

@Component({
selector: 'search-sort-by',
templateUrl: './sort-by.component.html',
})
export class SortByComponent implements OnInit {
choices = [
{
label: 'relevancy',
label: 'results.sortBy.relevancy',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how those strings will be reconized to be extracte d?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this particular case, I don't think we can rely on the extractor script - at some point this will not be hardcoded and we may have a list or config for this ... but I can restore the marker and use the npm script if it makes more sense ...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I think it's better to keep the translation keys being extracted. It's a good practice to let the script update the file.

at some point this will not be hardcoded and we may have a list or config for this

What do you mean exactly ?
If we update en.json manually to add foreign keys, it's the same effort to add them as markers in a dedicated file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also if we use npm run i18n:extract

{
	"search.field.any.placeholder": "Search datasets, services and maps ...",
	"results.layout.selectOne": "Results layout",
	"search.field.sortBy": "Sort by",
	"records": "records",
	"record.action.view": "viewable",
	"record.action.download": "downloadable",
	"record.more.details": "Read more",
	"results.records.hits.found=0.help": "Suggestions: <ul class='list-disc list-inside'><li>Try other words</li><li>Specify fewer words</li></ul>",
	"results.records.hits.found": "{hits, plural, =0{No documents match the specified search.} one{} other{{hits} records found.}}",
	"search.loading": "Loading ...",
	"results.sortBy.relevancy": "Relevancy",
	"results.sortBy.dateStamp": "Last updates",
	"results.sortBy.popularity": "Popularity",
	"dropFile": ""
}

which looks to be incomplete. Should we then add markers for all facets stuffs ? Web component translation like nav.back are also missing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it work well for the datafeeder app ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it work well for the datafeeder app ?

Not sure they are using, nobody read the manual ! :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we then add markers for all facets stuffs ?

IMO yes

Web component translation like nav.back are also missing.

Maybe it's just the path config in the package.json script

It helps to see some translations are missing, or some key are not well formatted, I keep thinking it's a good practice but I won't force it you find it painfull to maintain.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's see if it works. Markers added. Format consistent with prettier. Web component path fixed.

value: '_score',
},
{
label: 'last changed',
label: 'results.sortBy.dateStamp',
value: '-dateStamp',
},
{
label: 'popularity',
label: 'results.sortBy.popularity',
value: 'popularity',
},
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ <h1 class="truncate">{{ record.title }}</h1>
class="text-gray-500 text-xs border-gray-300 truncate viewable-downloadable"
*ngIf="isViewable || isDownloadable"
>
<span *ngIf="isViewable" translate>recordViewable</span>
<span *ngIf="isViewable" translate>record.action.view</span>
<span *ngIf="isViewable && isDownloadable">,&nbsp;</span>
<span *ngIf="isDownloadable" translate>recordDownloadable</span>
<span *ngIf="isDownloadable" translate>record.action.download</span>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h1 class="title-font text-lg font-medium text-gray-900 mb-3">
class="inline-flex items-center md:mb-2 lg:mb-0 hover:underline"
[href]="record.metadataUrl"
>
<span translate>readMore</span>
<span translate>record.more.details</span>
<svg
class="h-5 w-5"
xmlns="http://www.w3.org/2000/svg"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</div>
<div>
<ui-button type="secondary" (click)="clearFilter()" translate
>Back</ui-button
>nav.back</ui-button
>
<search-results-list-container></search-results-list-container>
</div>
Expand Down