# How to generate localized resources using Swift Package Plugins

**URL:** <https://forums.swift.org/t/how-to-generate-localized-resources-using-swift-package-plugins/68968>\
**Category:** Using Swift\
**Tags:** packagemanager, buildtoolplugin\
**Created:** [December 13, 2023, 3:39pm UTC](https://forums.swift.org/t/how-to-generate-localized-resources-using-swift-package-plugins/68968 "2023-12-13T15:39:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![code-per-day](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/code-per-day/32/32158_2.png) [@code-per-day](https://forums.swift.org/u/code-per-day)\
**Post date:** [December 13, 2023, 3:39pm UTC](https://forums.swift.org/t/how-to-generate-localized-resources-using-swift-package-plugins/68968/1 "2023-12-13T15:39:13Z")

</div>

We have a plugin which generates a `Localizable.strings` for each of our languages and places them in their respective `.lproj` folder. In order for the iOS app to detect and use those we need them to be generated at the root of their bundle.

I tried writing directly to `context.pluginWorkDirectory` but it creates the following structure:

```swift
MyPackage.bundle
  MyPlugin
    *.lproj

```

I tried appending a path component:

```swift
MyPackage.bundle
  MyDirectory
    *.lproj

```

And I tried appending the `..` path component, it fails which is understandable.

Are there any ways to ensure those `.lproj` find themselves at the root of the bundle? I need the following structure:

```swift
MyPackage.bundle
  *.lproj
    *.strings

```

---

<div class="post-metadata">

**Author:** ![NeoNacho](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/neonacho/32/1368_2.png) [@NeoNacho](https://forums.swift.org/u/NeoNacho)\
**Post date:** [December 13, 2023, 5:20pm UTC](https://forums.swift.org/t/how-to-generate-localized-resources-using-swift-package-plugins/68968/2 "2023-12-13T17:20:27Z")

</div>

The [WWDC session](https://developer.apple.com/wwdc22/110401) had an example involving localization, potentially that could be helpful here.

---

<div class="post-metadata">

**Author:** ![code-per-day](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/code-per-day/32/32158_2.png) [@code-per-day](https://forums.swift.org/u/code-per-day)\
**Post date:** [December 14, 2023, 4:40pm UTC](https://forums.swift.org/t/how-to-generate-localized-resources-using-swift-package-plugins/68968/3 "2023-12-14T16:40:25Z")

</div>

I rewatched it and they went quite quickly, not spending enough time on it to see much of a difference between their plugin and mine, could also be that `genstrings` writes them somewhere different?

Thought even pointing the tool to the root doesn't seem to work.
