Skip to content

Commit

Permalink
Merge pull request #9 from jordanebelanger/custom-workdir-fix
Browse files Browse the repository at this point in the history
Custom workdir fix
  • Loading branch information
miroslavkovac committed Jun 12, 2019
2 parents fc7c808 + ec198d4 commit 326f6ae
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Sources/LingoProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,19 @@ extension Container {
public struct LingoProvider: Vapor.Provider {

let defaultLocale: String
let rootPath: String
let localizationsDir: String

public init(defaultLocale: String, localizationsDir: String = "Localizations") {
self.defaultLocale = defaultLocale
self.rootPath = DirectoryConfig.detect().workDir + localizationsDir
self.localizationsDir = localizationsDir
}

public func register(_ services: inout Services) throws {
services.register(Lingo.self) { (container) -> (Lingo) in
return try Lingo(rootPath: self.rootPath, defaultLocale: self.defaultLocale)
let dirConfig = try container.make(DirectoryConfig.self)
let workDir = dirConfig.workDir.hasSuffix("/") ? dirConfig.workDir : dirConfig.workDir + "/"
let rootPath = workDir + self.localizationsDir
return try Lingo(rootPath: rootPath, defaultLocale: self.defaultLocale)
}
}

Expand Down

0 comments on commit 326f6ae

Please sign in to comment.