Latest 0.1.1
Homepage https://github.com/amnell/ResxSwift
License MIT
Platforms ios 9.0
Dependencies SWXMLHash
Authors

CI Status
Version
License
Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

To start using ResxSwift you first need to register your resx resource files:

guard let filePath_en = Bundle.main.path(forResource: "Resource.en", ofType: "resx") else { fatalError("File load error") }}
ResxSwift.shared.load(fileURL: URL(fileURLWithPath: filePath_en), language: "en", namespace: "Resource")

To use your loaded language resources all you need to do is:

ResxSwift.shared.localizedString("key")

Multiple languages and namespaces/resources

ResxSwift supports multiple languages and namespaces to make it easy for you to load multiple resources without them interfering with each other.

To load multiple resources, just make sure to supply the correct language and, if applicable, namespace.

guard let resourceFilePath_en = Bundle.main.path(forResource: "Resource.en", ofType: "resx") else { fatalError("File load error") }}
guard let clientFilePath_en = Bundle.main.path(forResource: "Client.en", ofType: "resx") else { fatalError("File load error") }}

ResxSwift.shared.load(fileURL: URL(fileURLWithPath: filePath_en), language: "en", namespace: "Resource")
ResxSwift.shared.load(fileURL: URL(fileURLWithPath: filePath_en), language: "en", namespace: "Client")

When loading a resource file you have to supply a language. To reference the language when fetching a localization you just supply the language, like: ResxSwift.shared.localizedString("key", language: "en")

Supplying a namespace is optional. If no namespace is supplied ResxSwift will infer namespace by extracting all characters from the filename up until the first period. Namespace.en.resx will result in Namespace as the namespace. To reference the namespace when fetching a localization you just supply the namespace, like: ResxSwift.shared.localizedString("key", namespace: "Namespace")

Default language

ResxSwift supports using a default language.

ResxSwift.shared.defaultLanguage = "en"

Note defaultLanguage will automatically be set to the initial language loaded.

Default namespace

ResxSwift supports using a default namespace.

ResxSwift.shared.defaultNamespace = "en"

Note defaultNamespace will automatically be set to the initial namespace loaded.

Installation

ResxSwift is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'ResxSwift'

Author

amnell, [email protected]

License

ResxSwift is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "ResxSwift",
    "version": "0.1.1",
    "summary": "ResxSwift makes it easy for you to use resx language resources to use forn  localization in your applications.",
    "description": "ResxSwift makes it easy for you to use resx language resources to use fornlocalization in your applications. Support for multiple resx namespaces andnlanguage. Also ability to set default fallback language and resx namespace.",
    "homepage": "https://github.com/amnell/ResxSwift",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "amnell": "[email protected]"
    },
    "source": {
        "git": "https://github.com/amnell/ResxSwift.git",
        "tag": "0.1.1"
    },
    "social_media_url": "https://twitter.com/amnell",
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "ResxSwift/Classes/**/*",
    "dependencies": {
        "SWXMLHash": [
            "~> 4.2.1"
        ]
    },
    "pushed_with_swift_version": "3.2"
}

Pin It on Pinterest

Share This