SilverStripe 3.5 - Fluent leads to 404 errors on translated pages - silverstripe

I'm using Fluent with Fluent Extra Table to translate my website.
My fluent.yml looks like this:
---
Name: myfluentconfig
After: '#fluentconfig'
---
Fluent:
default_locale: de_DE
disable_default_prefix: true
detect_locale: true
remember_locale: true
locales:
- de_DE
- en_US
aliases:
de_DE: de
en_US: en
---
Name: myfluenti18nconfig
After: '#fluenti18nconfig'
---
i18n:
default_locale: de_DE
Accessing the default language (German) is no problem, switching the language also works, but if the page has an changed url segment, I always receive a 404 - not found error.
For example:
German: domain.tld/kontakt works
English: domain.tld/en/kontakt works
English: domain.tld/en/contact 404 error
Any ideas how to solve that?
Edit:
The translated URLSegment get's in the table sitetree_en_us in the column URLSegment_en_US. But It seems that SilverStripe is only using the URLSegment stored in the sitetree table and that's the "default/german" one.

Related

What "resource: |" does mean in routes.yaml?

I'm trying to figure out with Sylius routing, based on Symfony framework. I found that code
sylius_admin_channel:
resource: |
alias: sylius.channel
section: admin
templates: "#SyliusAdmin\\Crud"
except: ['show']
redirect: update
grid: sylius_admin_channel
permission: true
vars:
all:
subheader: sylius.ui.configure_channels_available_in_your_store
templates:
form: "#SyliusAdmin/Channel/_form.html.twig"
index:
icon: share alternate
type: sylius.resource
But I could not find any information what is it | for resource. Any help?
Thanks.
It's the YAML syntax for a multi-line string (that preserves newlines).
So sylius_admin_channel is a mapping that has two keys (resource and type) whose values are both string types.
It can be confusing to see in this instance because the string happens to also be valid YAML. I edited your question to include syntax highlighting for YAML which makes this a little more obvious, visually.
If I didn't know any better, I would have guessed that the | is there in error and resource should actually have a mapping type for its value. If you remove the |, then same symbols that were within that string still produce valid YAML for the whole file, but the value of resource would be a mapping, rather than a string.
Notice the difference in syntax highlighting, compared to the yaml in the question with the | removed:
sylius_admin_channel:
resource:
alias: sylius.channel
section: admin
templates: "#SyliusAdmin\\Crud"
except: ['show']
redirect: update
grid: sylius_admin_channel
permission: true
vars:
all:
subheader: sylius.ui.configure_channels_available_in_your_store
templates:
form: "#SyliusAdmin/Channel/_form.html.twig"
index:
icon: share alternate
type: sylius.resource

Symfony pagerfanta - can't translate the text in final pagination

I'm trying to translate from english the next and previous in pagination.
I've tried creating normal pagerfanta.cs.yaml with Previous: "Předchozí" Next: "Následující" and pagerfanta even has its own translations so it should work by itself, but copying the original pagerfanta.cs.xliff to the translations folder doesn't work either.
In services.yaml I have:
parameters:
locale: 'en'
and in translation.yaml:
framework:
default_locale: cs
translator:
default_path: '%kernel.project_dir%/translations'
fallbacks:
- '%locale%'
Symfony debug toolbar also doesn't even catch any translations should take place.
Any ideas why it's not working?
You should install pagerfanta/twig package in order to use translatable templates. Then create a new config file at config/packages/babdev_pagerfanta.yaml containing
babdev_pagerfanta:
default_view: twig
default_twig_template: '#BabDevPagerfanta/twitter_bootstrap5.html.twig'
By selecting twig as default_view, the translations are going to be handled properly.

Default Locale is not showing as href link in Symfony 3.4

I run Symfony 3.4 in my local and added locale in default and routes. Given below:
in app/config.yml
framework:
default_locale: "en"
in Routes I have
homepage:
path: /{_locale}
defaults: { _controller: AcmeBundle:Home:index, _locale: en }
and in twig I have:
{% set en_params = app.request.attributes.get('_route_params') | default([]) | merge(app.request.query) %}
{% set en_params = en_params | merge({'_locale': 'en'}) %}
<span>English</span>
The expected output should be http://localhost/en when I will hover on anchor tag or click
but it is overriding with the default locale and showing http://localhost
Thanking you in advance to provide me the right way or correct me if I am wrong.
if an optional parameter (the {_locale} parameter) is at an optional position (i.e. the end) and is also the default, it can (and apparently will) be omitted. The same is true for {_format} and even for .{_format} (additional dot)
I think, as long as it works, why do you care?
You can maybe force the parameter by explicitly defining the _locale requirement to be [a-z]{2} (or even more explicitly de|en) but I'm not entirely certain.

Cannot import resource error, FosRestBundle Throws InvalidArgumentException

Hello i have a strange problem, while using FostRestBundle.
First error is :
InvalidArgumentException: Every parent controller must have get{SINGULAR}Action($id) method
where {SINGULAR} is a singular form of associated object
And the second one :
Cannot import resource "/home/a15net/public_html/game/src/ATL/ContentBundle/Resources/config/api_routing.yml" from "/home/a15net/public_html/game/app/config/routing.yml".
I'v checked my all "YAML" files but there was no indent problems.
Tried to update composer twice nothing helped.
Edit : Config.yml > http://goo.gl/dqCAu
You have to remove the 'type' from this import statement fro your routing.yml
atl_content_api:
resource: "#ATLContentBundle/Resources/config/api_routing.yml"
Inside the api_routing.yml you can specify the rest type for each controller like,
acme_user_rest:
resource: Acme\UserBundle\Controller\UserRestController
prefix: /api
type: rest
this blog will help you to implement the sme
--- NOT --- SOLUTION :
If a route has a parent route, you must not put "type:rest" to it. You have to use "type:rest" only in parent routes.
Sample :
catalogs:
type: rest
prefix: api
resource: ATL\CatalogBundle\Controller\API\CatalogsController
options:
expose: true
taxonomy:
parent: catalogs
resource: ATL\CatalogBundle\Controller\API\TaxonomyController
options:
expose: true
I will not choose this as correct answer until more comments and other solution suggestions writed.
Edit
When you remove type:rest from children route, it is not a rest route anymore.

Searching through multilingual records using ElasticaBundle & Translatable

I've created a multi-lingual website with Symfony2 using the (Gedmo) Translatable behavior extension for Doctrine2. This works fine but now i'm looking for a way to use the ElasticaBundle to create a nice searchoption. I want German users to search in the German-translation but also in the English translation.
At the moment i'm trying to use separate indexes for each language. My config.yml looks like this:
foq_elastica:
clients:
default: { host: localhost, port: 9200 }
indexes:
articles_en:
client:default
types:
article:
mappings:
name: { boost: 5, analyzer: my_analyzer }
persistence:
driver: orm
model: Test\SiteBundle\Entity\Article
identifier: id
provider:
service: elastica.translation.provider.article.en
finder:
articles_de:
....
articles_nl:
.....
This works fine if you want to search through one index but searching two indexes seems not possible with this bundle or am I wrong?
Is there a way to do this? Any help will be appreciated!
Rick
You should probably just add one index for every article in every language and add a language to your index. You can then search your index for articles in one or more languages.

Resources