Skip to content

Commit

Permalink
warning for multiple language matches
Browse files Browse the repository at this point in the history
  • Loading branch information
oxisto committed Jul 18, 2024
1 parent 8647126 commit e63c4ed
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,21 @@ private constructor(
} else null
}

/**
* This extension function returns an appropriate [Language] for this [File] based on the
* registered file extensions of [TranslationConfiguration.languages]. It will emit a warning if
* multiple languages are registered for the same extension (and the first one that was
* registered will be returned).
*/
private val File.language: Language<*>?
get() {
return config.languages.firstOrNull { it.handlesFile(this) }
val languages = config.languages.filter { it.handlesFile(this) }
if (languages.size > 1) {
log.warn(
"Multiple languages match for file extension ${this.extension}, the first registered language will be used."
)
}
return languages.firstOrNull()
}

class Builder {
Expand Down

0 comments on commit e63c4ed

Please sign in to comment.