mirego / accent

The first developer-oriented translation tool. True asynchronous flow between translators and your team.
https://www.accent.reviews
BSD 3-Clause "New" or "Revised" License
1.29k stars 97 forks source link

Add option to only sync one specific file with namePattern `parentDirectory` #407

Closed RappyTV closed 9 months ago

RappyTV commented 9 months ago

I have this accent.json:

{
    "apiUrl": "--",
    "files": [
        {
            "namePattern": "parentDirectory",
            "format": "json",
            "source": "locales/%slug%.json",
            "target": "locales/%slug%.json"
        }
    ]
}

and I have 2 files in my accent - addon and api. But in this program (the API) I only need to use the api file and in the other one I only want to use the addon file. It would be pretty awesome to have a key file in the accent.json which then only syncs a specific file. That would also make sense because the files is an array...

I understand that I could just create a second project but this would look pretty unorganized in my opinion.

simonprev commented 9 months ago

Yeah this is a "feature" that I added recently but after using it (and having a bunch of bug report internally 😄 ) I think it was a mistake. The CLI should only sync what matches in the files config. It will be fix in the next CLI release.

RappyTV commented 9 months ago

is there an ETA for that?

simonprev commented 9 months ago

I want to test locally and merge https://github.com/mirego/accent/pull/404 before doing the release. My goal is this week 😃

RappyTV commented 9 months ago

okay thanks a lot :D

simonprev commented 9 months ago

Done! 0.16.0 has been published to npm

RappyTV commented 9 months ago

But how would I now only fetch the addon translation? Do I have to pass a parameter or some property in the accent.json?

RappyTV commented 7 months ago

But how would I now only fetch the addon translation? Do I have to pass a parameter or some property in the accent.json?

@simonprev please I need help with this. i think you misunderstood my original issue

simonprev commented 7 months ago

If you only want 1 file to sync in this project, you can remove the "wildcard" match in the config:

{
    "apiUrl": "--",
    "files": [
        {
            "namePattern": "parentDirectory",
            "format": "json",
            "source": "locales/addon.json",
            "target": "locales/%slug%.json"
        }
    ]
}

The source will only be "addon.json" and it will ignore the rest of the files uploaded in your Accent project.

RappyTV commented 7 months ago

If you only want 1 file to sync in this project, you can remove the "wildcard" match in the config:

{
    "apiUrl": "--",
    "files": [
        {
            "namePattern": "parentDirectory",
            "format": "json",
            "source": "locales/addon.json",
            "target": "locales/%slug%.json"
        }
    ]
}

The source will only be "addon.json" and it will ignore the rest of the files uploaded in your Accent project.

Well I tried it but it always pulls the api.json regardless of what I put into the source value. The CLI also always returns that it pulled the api.json:

Fetch config in accent.json... API Client ✓

Syncing sources → en_us  ✓

Adding translations paths → de_de ✓

Writing files locally

   ↓ locales/en_us.json api → en_us
   ↓ locales/de_de.json api → de_de

For more informations on operations: https://www.accent.reviews/guides/glossary.html#sync
Syncing took 2145 milliseconds, completed without issues

So it's practically impossible for me to pull the addon.json

RappyTV commented 7 months ago

If you only want 1 file to sync in this project, you can remove the "wildcard" match in the config:


{

    "apiUrl": "--",

    "files": [

        {

            "namePattern": "parentDirectory",

            "format": "json",

            "source": "locales/addon.json",

            "target": "locales/%slug%.json"

        }

    ]

}

The source will only be "addon.json" and it will ignore the rest of the files uploaded in your Accent project.

Well I tried it but it always pulls the api.json regardless of what I put into the source value. The CLI also always returns that it pulled the api.json:


Fetch config in accent.json... API Client ✓

Syncing sources → en_us  ✓

Adding translations paths → de_de ✓

Writing files locally

   ↓ locales/en_us.json api → en_us

   ↓ locales/de_de.json api → de_de

For more informations on operations: https://www.accent.reviews/guides/glossary.html#sync

Syncing took 2145 milliseconds, completed without issues

So it's practically impossible for me to pull the addon.json

@simonprev