How can I download different files to different paths?

I have source files in two different folders, and I want the downloaded translations to be placed the same folder the corresponding source file is located in.

From reading the documentation, I understand that we can use groups to filter download rules. I couldn’t find a clear clear code example of doing that in the documentation, but I tried to accomplish that this way:

"upload": {
    "files": [
      {
        "type": "ios-strings",
        "pattern": "App/en.lproj/Localizable.strings"
      },
      {
        "type": "ios-stringsdict",
        "pattern": "App/en.lproj/Localizable.stringsdict"
      },
      {
        "type": "ios-strings",
        "group": "screenshots",
        "pattern": "fastlane/screenshots/en-US/title.strings"
      }
    ]
  },

  "download": {
    "files": [
        {
            "group": "screenshots",
            "stop": true,
            "output": "fastlane/screenshots/${lang}/${file}"
        },
        "App/${iosLprojFolder}/${file}"
    ]
  }
}

When I run localazy download, all the translated files go into the App folder. Am I doing something wrong here?

Hello,

you can send path along with the file name. It’s not sent by default, but you can change the upload section like this:

{
  "upload": {
    "files": [
      {
        "type": "ios-strings",
        "pattern": "App/en.lproj/Localizable.strings",
        "path": "..."
      }
    ]
  }
}

You can use the automatic property ${autodetectPath}, but I recommend you to always run localazy upload -s to simulate the request and see what is to be sent to the server.

You can also clean up the path using transformations so that what you send to the server is in the desired format.

Please beware that a different path means also a different file on Localazy.


The second option is to use conditions.

You can filter the file in the download section based on its name like this:

{
  "download": {
    "files": [
        {
          "group": "screenshots",
          "stop": true,
          "output": "fastlane/screenshots/${lang}/${file}",
          "conditions": "equals: title.strings, ${file}"
        },
        {
          "stop": true,
          "output": "App/${iosLprojFolder}/${file}",
          "conditions": "!equals: title.strings, ${file}"
        }
    ]
  }
}
1 Like

Thanks! I ended up using the second solution so I wouldn’t have to change the upload configuration. For some reason I hadn’t thought to try filtering on the file name.

1 Like