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

Feature request: Ability to localize page's param in URL #16

Open
tranduyhung opened this issue Apr 15, 2016 · 6 comments
Open

Feature request: Ability to localize page's param in URL #16

tranduyhung opened this issue Apr 15, 2016 · 6 comments

Comments

@tranduyhung
Copy link

tranduyhung commented Apr 15, 2016

It is great if the plugin gives an option to change "page" param in URL to something else, like for localization.

For example, I would like to have

myblog.com/bai-viet/trang:10

instead of

myblog.com/bai-viet/page:10

"trang" means "page" in my language.

I looked into the code and I was able to change "page" to a different word, but the page's result was only from page 1 and the pagination only activated page 1, I couldn't browse pages 2+.

@marcocevoli
Copy link

Hi, I'm also interested in this. I've tried to replace $this->items[$x] = new PaginationPage($x, '/page' . $config->get('system.param_sep') . $x); with $this->items[$x] = new PaginationPage($x, '/'. $grav['language']->translate('PLUGIN_PAGINATION.PAGE') . $config->get('system.param_sep') . $x); in classes/plugin/PaginationHelper.php but I got the same error as @tranduyhung
Looking forward to seeing someone taking it from here and suggest a pull request.

@ricardo118
Copy link

Ive looked into this and the problem is here:

    public function currentPage()
    {
        $page = (int)($this->params['page'] ?? 1);

        return max(1, $page);
    }

This function from Grav/Common/Uri is hardchecking the 'page' param. changing it to something like this:

    public function currentPage()
    {
        $page = (int)($this->params[Grav::instance()['language']->translate('PLUGIN_PAGINATION.PAGE')]] ?? 1);

        return max(1, $page);
    }

does work for returning the appropriate page but may have some effects on other things

@ricardo118
Copy link

what is your opinion @mahagr @rhukster ?

@mahagr
Copy link
Member

mahagr commented Aug 4, 2020

Above does not work as it doesn't change the parameter name in the templates and I don't think that it's used so much either.

I'm not sure if it's best to use translation like that, especially as it gets translated to Chinese etc.. Might be better to use something like PAGE_URL_ATTRIBUTE and add a comment to it what it is used for.

@ricardo118
Copy link

oh yeah theres a couple more modifications that are needed for it to work, we got it working
this is the only function thats directly from core. But yeah a diff translation name than just page is better i agree

@Sogl
Copy link
Contributor

Sogl commented Jul 12, 2022

Ran into this issue today. Any plans to change this behavior?

WordPress uses only the number of pages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants