Improve i18n string handling

* Fall back to default language on missing translation file
* Add a i18n-warnings build flag
* If that flag is set, print a parseable and greppable string on missing translation strings

See #2303
This commit is contained in:
Bjørn Erik Pedersen
2016-08-09 11:41:56 +02:00
parent 8da040342e
commit f1e1cdab3f
3 changed files with 51 additions and 16 deletions

View File

@@ -25,6 +25,8 @@ import (
"sync"
"time"
"github.com/spf13/hugo/tpl"
"github.com/spf13/hugo/hugofs"
"github.com/spf13/hugo/parser"
@@ -242,6 +244,7 @@ func initHugoBuildCommonFlags(cmd *cobra.Command) {
cmd.Flags().BoolVar(&preserveTaxonomyNames, "preserveTaxonomyNames", false, `Preserve taxonomy names as written ("Gérard Depardieu" vs "gerard-depardieu")`)
cmd.Flags().BoolVarP(&forceSync, "forceSyncStatic", "", false, "Copy all files when static is changed.")
cmd.Flags().BoolVarP(&noTimes, "noTimes", "", false, "Don't sync modification time of files")
cmd.Flags().BoolVarP(&tpl.Logi18nWarnings, "i18n-warnings", "", false, "Print missing translations")
// Set bash-completion.
// Each flag must first be defined before using the SetAnnotation() call.