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

[RFC] Translate taxonomies #198

Closed
COOLak opened this issue Jan 6, 2019 · 2 comments
Closed

[RFC] Translate taxonomies #198

COOLak opened this issue Jan 6, 2019 · 2 comments

Comments

@COOLak
Copy link
Contributor

COOLak commented Jan 6, 2019

There's no mentioning of any way to translate taxonomies in the documentation, so I suppose there's no way to do it. Basically the only way is to have English taxonomies for all languages or have them in all languages at the same time, which doesn't look right. For example, on my website, I have a taxonomy called Categories, which includes News and Articles. At the bottom of each record there's output of the respective taxonomy (Category: News / Category: Articles). Visitors of different language version will not understand what that is.

@COOLak
Copy link
Contributor Author

COOLak commented Jan 6, 2019

For anyone else who's come to face the same issue, I managed to make a workaround. Basically, you create additional taxonomies that end with '_locale' (e. g. _es for Spanish). So you have both 'categories' and 'categories_es', both 'tags' and 'tags_es'. Then you modify your _sub_taxonomylinks.twig in the following way (I use subdomain approach, use your own conditions that suite you). This allows to only show language-specific taxonomies depending on the url of the website.

<div class="tags">
	{% for type, values in record|taxonomy %}
		{% set domain = app.request.getHttpHost() %}
		{% if ((domain == 'es.domain.com') and '_es' in type) or ((domain == 'en.domain.com') and '_es' not in type) %}
			<span class="label">
				{% if values|length < 2 %}
					{{ config.get('taxonomy')[type].singular_name }}:
				{% else %}
					{{ config.get('taxonomy')[type].name }}:
				{% endif %}
			</span>
			{% for link, value in values %}
				<a href="{{ link }}" class="tag is-dark">{{ value }}</a>
			{% else %}
				{{ __('general.phrase.none') }}
			{% endfor %}
		{% endif %}
	{% endfor %}
</div>

@COOLak
Copy link
Contributor Author

COOLak commented Jan 21, 2019

Well, another option is to just use Labels. At the time of submitting this RFC I wasn't fully aware that it's capable of doing this on its own. But the above method could still be useful for those who want to have taxonomy links different for other languages.

@COOLak COOLak closed this as completed Mar 19, 2019
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

1 participant