Internationalization #578
Replies: 18 comments 1 reply
-
I know this is old but I think this hasn't been addressed yet and it is preventing me from using Jigsaw in a lot of projects :( Any idea to work something out with current implementation of Jigsaw? Any idea if this is ever gonna be solved? Thank you! |
Beta Was this translation helpful? Give feedback.
-
Yes, it's the most-requested feature at the moment! Can you give a little more detail about what your needs are? We'd need to sort out how to define the current locale, presumably by specifying a language code as part of the URI; and then perhaps indicating which languages to use for a particular template by specifying the language codes in the YAML front matter of the template. |
Beta Was this translation helpful? Give feedback.
-
Oh, this is really great to hear! I guess my needs are quite simple, nothing fancy:
FYI I've been using LaravelLocalization since before Laravel introduced its custom translation system and it's been great. Actually way better than the built-in system. Thank you :) and thanks for your quick response. |
Beta Was this translation helpful? Give feedback.
-
We're gonna be working on this feature soon, and would love to get input on what people think would be the most useful and user-friendly way to handle internationalization. Keeping close to Laravel's implementation of things like |
Beta Was this translation helpful? Give feedback.
-
Hi, I personally like to use I really like the way Laravel let's users choose their own directory structure inside For the folks that use |
Beta Was this translation helpful? Give feedback.
-
You can somewhat do this already, and in fact I wonder if having language as a collection isn't really the best solution for an internationalized site—considering that the number of languages is likely small, not subject to frequent change, and doesn't require many of the features that collections is designed to provide (you don't generally need to do things like change the sort order of languages, see a paginated subset of languages, count them, etc.). I'm not opposed to considering the concept of nested collections, but it would be worth considering other scenarios where that would be useful, before we go down that road. To do what you outlined above, you could do something like this. In <?php
return [
'baseUrl' => 'https://example.com',
'path' => '{language}/{type}/{-title}',
'collections' => [
'posts-sl' => [
'type' => 'blog',
'language' => 'sl',
],
'posts-en' => [
'type' => 'blog',
'language' => 'en',
],
],
]; ...and then store your translated blog posts in which would build to this: Note that I'm using I threw in non-collection translated pages as well, So you'd end up with:
The issues I'd like to sort out are:
|
Beta Was this translation helpful? Give feedback.
-
@damiani Your proposition perfectly describes my use case! Also, actually including Slovene text in them, made me laugh. You've made my day again :) |
Beta Was this translation helpful? Give feedback.
-
Hi again, I'm giving it a try and outlining my concerns once tested. But I think that, using this approach, there's no way I could provide a user (ang Google) the alternative lang link (i.e. But just as I said, i'll give it a go and come back with some ideas or feedback. |
Beta Was this translation helpful? Give feedback.
-
@morpheus7CS Blame Google for any translation errors :) @afontcu Yes, please report back with your thoughts. You could have alternative links for users/Google pretty easily if you weren't customizing the blog post title by language (i.e. |
Beta Was this translation helpful? Give feedback.
-
Hi there! Been testing the approach outlined above and while it covers 80% of the requirements of a translated site, there are some important flaws:
Thank you very much! |
Beta Was this translation helpful? Give feedback.
-
I was thinking about pagedata which has an array of locales to render the page in. This locale property can later on be used in url generators and as a parameter for the illuminate/translation provided translator. |
Beta Was this translation helpful? Give feedback.
-
I'm also building a multi-locale site, and realized that you can include
Then you can define a 'master' layout for each page (e.g. about-us, services, home), an extend the layout specifying only page metadata. For example, you can have a master 'about-us' layout in
And locale-specific pages in
and
With this setup, translation strings can be organized in the same way as in a regular Laravel project. This is something that I only quickly tested, and it works. I'm not sure how slow the build will get with more translation strings - it can probaly be optimized by loading |
Beta Was this translation helpful? Give feedback.
-
I like both approaches, but in @amadeann's approach: what if you want to translate a whole post with HTML inside (e.g. for formatting)? Do you keep all that in the translation strings? |
Beta Was this translation helpful? Give feedback.
-
If the formatting is very different between languages, and the layout changes as well, then just create separate pages. If you need minor formatting (like wrapping some text in |
Beta Was this translation helpful? Give feedback.
-
I followed @damiani 's suggestions, but how do you access the blog posts then? If the blog is just called |
Beta Was this translation helpful? Give feedback.
-
Certainly keeping an eye on this thread, as I'm trying jigsaw for a simple project and I like its workflow. Structuring the files for a multilingual site, with different content types, has been certainly a challenge. After reading all the thread, I see this issue is still open and attracts attention. @damiani Is there a roadmap for this? |
Beta Was this translation helpful? Give feedback.
-
Hello guys 👋🏽 checkout the library Jigsaw Localization that I have just released. I am excited to get some feedback and see it being useful you |
Beta Was this translation helpful? Give feedback.
-
I implemented some level of internationalization on my Jigsaw project. You can see it at https://gitlab.com/islam-answers/website/-/tree/c9b999bbd2c2634a1c098206395884196f3c4930/app My directory structure looks like this:
The only thing I wish I could fix is using the same filename for posts in different language directories. #674 (comment) To workaround this, right now I'm adding a language suffix to filenames (my-post-title.en.blade.md) I had to add some helpers to make things work, so you might find that interesting to look at, too. https://gitlab.com/islam-answers/website/-/blob/c9b999bbd2c2634a1c098206395884196f3c4930/app/config.php I linked to a specific commit because I'm soon integrating Lokalise, and I might update the implementation to make it work better with Lokalise. |
Beta Was this translation helpful? Give feedback.
-
Would be cool also to be able to use the
trans()
helper to load translated content within a static site also...Beta Was this translation helpful? Give feedback.
All reactions