diff --git a/docs/guide/api/props.md b/docs/guide/api/props.md index ae9e54f..a720af1 100644 --- a/docs/guide/api/props.md +++ b/docs/guide/api/props.md @@ -19,3 +19,9 @@ Limit of pages to be rendered. `0` shows all pages (default). `-1` will hide num * `Boolean` (optional) When `true`, the pagination component will keep the same length regardless of the position of the page number. This is useful when you want to keep the pagination component always the same size and not vary at the first or last pages. The `limit` prop is used to determine the length of the pagination. + +## lang + +* `String` (optional) + +The default lang value is `en-US`. Translating page numbers depends on Javascript toLocaleString method. diff --git a/src/Bootstrap4Pagination.vue b/src/Bootstrap4Pagination.vue index 4c953a1..d60aa80 100644 --- a/src/Bootstrap4Pagination.vue +++ b/src/Bootstrap4Pagination.vue @@ -3,6 +3,7 @@ :data="data" :limit="limit" :keep-length="keepLength" + :lang="lang" @pagination-change-page="onPaginationChangePage" v-slot="slotProps" > @@ -28,7 +29,7 @@
  • - {{ page }} + {{ slotProps.translatePage(page) }} (current)
  • @@ -53,7 +54,7 @@ export default { compatConfig: { MODE: 3 }, - + inheritAttrs: false, emits: ['pagination-change-page'], @@ -92,7 +93,11 @@ export default { validator: value => { return ['left', 'center', 'right'].indexOf(value) !== -1; } - } + }, + lang: { + type: String, + default: 'en-US', + }, }, methods: { diff --git a/src/Bootstrap5Pagination.vue b/src/Bootstrap5Pagination.vue index 6564280..2faab3c 100644 --- a/src/Bootstrap5Pagination.vue +++ b/src/Bootstrap5Pagination.vue @@ -3,6 +3,7 @@ :data="data" :limit="limit" :keep-length="keepLength" + :lang="lang" @pagination-change-page="onPaginationChangePage" v-slot="slotProps" > @@ -27,7 +28,7 @@
  • - {{ page }} + {{ slotProps.translatePage(page) }}
  • @@ -50,7 +51,7 @@ export default { compatConfig: { MODE: 3 }, - + inheritAttrs: false, emits: ['pagination-change-page'], @@ -89,7 +90,11 @@ export default { validator: value => { return ['left', 'center', 'right'].indexOf(value) !== -1; } - } + }, + lang: { + type: String, + default: 'en-US', + }, }, methods: { diff --git a/src/RenderlessPagination.vue b/src/RenderlessPagination.vue index 857b09f..175dfd9 100644 --- a/src/RenderlessPagination.vue +++ b/src/RenderlessPagination.vue @@ -15,6 +15,10 @@ export default { type: Boolean, default: false, }, + lang: { + type: String, + default: 'en-US', + }, }, computed: { @@ -195,6 +199,12 @@ export default { this.selectPage(page); }, }), + translatePage: (page) => { + if (typeof page !== 'number') { + return page; + } + return page.toLocaleString(this.lang); + }, }); }, }; diff --git a/src/TailwindPagination.vue b/src/TailwindPagination.vue index 570a7bb..760e5bb 100644 --- a/src/TailwindPagination.vue +++ b/src/TailwindPagination.vue @@ -3,6 +3,7 @@ :data="data" :limit="limit" :keep-length="keepLength" + :lang="lang" @pagination-change-page="onPaginationChangePage" v-slot="slotProps" > @@ -41,7 +42,7 @@ v-on="slotProps.pageButtonEvents(page)" :disabled="page === slotProps.computed.currentPage" > - {{ page }} + {{ slotProps.translatePage(page) }}