Jump to content

How to translate the arbitrary cyrillic string into another language so that it can be used as a name?


Clarity
 Share

Recommended Posts

Hello everyone!

I have a cyrillic string transliteration of which I want to use as a name for the new page via cloning another page with a custom title. I'm using this function:

function foo($copyFromPage$parent$newTitle$language) {
    $copyFromPage->of(false);
    $clone = wire('pages')->clone($copyFromPage);
    $clone->of(false);
    $clone->title->setLanguageValue(wire('languages')->get($language), $newTitle);
    $clone->name = $newTitle;
    $clone->parent = $parent;
    wire('pages')->save($clone, ['ignoreFamily' => true]);
}

Usage of my function is like:

foo(65536, 32768, 'Новая страница', 'ru');

I need to translate 'Новая страница' into a name like novaya-stranitsa in order to have a page to be named correctly (now I have hyphen instead of name). Could you please tell me how to do it in ProcessWire?

Link to comment
Share on other sites

Hi,

i don't know if it's what you are looking for but in pw, you have a setting tab for each page where you can set whatever name you want, even completely different from the page title

a little trick that may help, when creating a page pw auto fill the name field based on the title you choose, what i do when i want them different, i first fill the name and the title afterwards 🙂

have a nice day

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...