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

Loco tags management #45

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

yoannlecoguic
Copy link

With this patch, you can specify tags for loco, and it will get the associated translation filtered by this tags.

The generated translation filename is like 'domain-tag-tag...'
Add this in your happyr_translation.yml config file :
project:
    domain:
            tags:
                    [LOCALE]:
                            - '[TAG1]'
                            - '[TAG2]'

…ssociated translation filtered by this tags.

    The generated translation filename is like 'domain-tag-tag...'
    Add this in your happyr_translation.yml config file :
    project:
        domain:
                tags:
                        [LOCALE]:
                                - '[TAG1]'
                                - '[TAG2]'
@Nyholm
Copy link
Member

Nyholm commented Oct 26, 2016

Cool, I'll try to find some time to review and test this PR later this week.

@yoannlecoguic
Copy link
Author

Thanks ! I changed the behavior for something like :
domain:
tags:
[LOCALE]:
- '[TAG1]'
- '[TAG2]'

I need to expose some translations in the front-end of my application.
So i decided to generate a filtered file for every locales of a project.

Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not really understand the implementation. Some clarifications would be great =)

@@ -429,6 +429,16 @@ protected function getUrls(array &$data, array $config, $domain, $useDomainAsFil
$fileName = sprintf('%s.%s.%s', $domain, $locale, $this->filesystemService->getFileExtension());

$data[$url] = $fileName;

if (count($config['tags']) !== 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use empty


// Build url
$url = sprintf('%sexport/locale/%s.%s?%s', self::BASE_URL, $locale, $this->filesystemService->getFileExtension(), http_build_query($query_tags));
$fileName = sprintf('%s.%s.%s', $domain.'-'.(implode($config['tags'], '-')), $locale, $this->filesystemService->getFileExtension());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of the tags?
It looks like you building another URL here. The result would be that you download all translations AND translation filtered with tags.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my project, i need two files per locale : one for back-end translations, where i take all translations, and one for front-end translations, where i select translations using tags (in order to have minify the file size).

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

Successfully merging this pull request may close these issues.

2 participants