BoltTranslate / Translate

Provides translation for contenttypes.
Other
43 stars 37 forks source link

How to translate Content Type Slug #80

Closed Mariyo closed 7 years ago

Mariyo commented 7 years ago

Hello, is it possible to translate Content Type slug also?

lswest commented 7 years ago

Yes, but you will need to create custom routes. This was a recommendation from @SahAssar the other day, when he was helping me with another issue.

For an example, see below. The first two entries translate my content type "ueber" into both English (/en/about-us/) and German (/de/ueber-uns/). The third entry just configures the normal pages content type to work with en and de (and translateable slugs), and the last two entries simply configure the homepage redirect to language (from the extension), and the normal homepage translations (so the URLs exist for the redirect). Let me know if you have any questions!

about-us:
    path:               /en/about-us/{slug}
    defaults:           { _controller: 'Bolt\Controllers\Frontend::record', 'contenttypeslug': 'ueber', '_locale': 'en' }
    contenttype:        ueber

ueber:
    path:               /de/ueber-uns/{slug}
    defaults:           { _controller: 'Bolt\Controllers\Frontend::record', 'contenttypeslug': 'ueber', '_locale': 'de' }
    contenttype:        ueber

pages:
    path:               /{_locale}/{slug}
    defaults:           { _controller: 'Bolt\Controllers\Frontend::record', 'contenttypeslug': 'pages' }
    contenttype:        pages
    requirements:
        _locale:        en|de

homepage:
    path:               /{_locale}
    defaults:           { _controller: 'Bolt\Controllers\Frontend::homepage' }
    requirements:
        _locale:        en|de

homepageredir:
    path:               /
    defaults:           { _controller: 'controller.frontend:homepageRedirect'}
SvanteRichter commented 7 years ago

Thanks @lswest for answering! I'm going to close this, but @Mariyo feel free to reopen if you run into trouble with it!

Mariyo commented 7 years ago

Thx for response, just wondering case we have 10 languages and 10 content types... Pretty huge admin menu :)

I like this extension: https://github.com/AnimalDesign/bolt-translate. Unfortunately, I dont like how data are stored. Maybe combination of both solutions could result into something usefull.