Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carl Kittelberger committed Feb 9, 2017
0 parents commit fa26623
Show file tree
Hide file tree
Showing 23 changed files with 1,014 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
root = true

[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = true

[*.json]
indent_style = space
indent_size = 2
insert_final_newline = false

[*.{yaml,yml}]
indent_style = space
indent_size = 4
insert_final_newline = true
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so

# Folders
_obj
_test

# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out

*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*

_testmain.go

workreportmgr
*.exe
*.test
49 changes: 49 additions & 0 deletions export/latex/export.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package latex

import (
"io"
"text/template"

"github.com/nicksnyder/go-i18n/i18n"

"git.dekart811.net/icedream/workreportmgr/project"
)

// TexMarker represents information about a TeX document to be read in by the
// respective compiler. It contains information for example about which TeX
// variant to use.
type TexMarker struct {
Program string
}

// Exporter provides functionality to export a workreports project to a LaTeX
// file.
type Exporter struct {
Locale string
Inputs []string
Marker TexMarker
}

// Export generates LaTeX code from the given project and writes it to the given
// writer.
func (e *Exporter) Export(prj *project.Project, w io.Writer) (err error) {
T, err := i18n.Tfunc(e.Locale)
if err != nil {
return
}

exportTemplate.Funcs(template.FuncMap{
"T": T,
})

data := struct {
Project *project.Project
TexMarker TexMarker
TexInputs []string
}{
Project: prj,
TexInputs: e.Inputs,
TexMarker: e.Marker,
}
return exportTemplate.Execute(w, data)
}
6 changes: 6 additions & 0 deletions export/latex/init.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package latex

func init() {
initLocalization()
initTemplate()
}
29 changes: 29 additions & 0 deletions export/latex/localization.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package latex

import (
"log"

"github.com/nicksnyder/go-i18n/i18n"
)

//go:generate go-bindata -pkg latex -o localization_assets.go localization/

func initLocalization() {
log.Println("Initializing localization for LaTeX export...")

files, err := AssetDir("localization")
if err != nil {
log.Fatal("Failed to browse embedded asset directory.", err)
panic(err)
}

for _, file := range files {
if localizationBytes, err := Asset("localization/" + file); err != nil {
log.Fatal("Failed to read localization file.", err)
panic(err)
} else if err := i18n.ParseTranslationFileBytes(file, localizationBytes); err != nil {
log.Fatal("Failed to parse localization file.", err)
panic(err)
}
}
}
54 changes: 54 additions & 0 deletions export/latex/localization/de-de.all.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[
{
"id": "calendar_week",
"translation": "Kalenderwoche"
},
{
"id": "calendar_week_short",
"translation": "KW"
},
{
"id": "department",
"translation": "Abteilung"
},
{
"id": "instructor",
"translation": "Ausbilder/in"
},
{
"id": "legal_representative",
"translation": "Gesetzlicher Vertreter"
},
{
"id": "name",
"translation": "Name"
},
{
"id": "no_school_periods_this_week",
"translation": "Hat in dieser Woche noch nicht stattgefunden."
},
{
"id": "operational_activities",
"translation": "Betriebliche Tätigkeiten"
},
{
"id": "operational_instruction",
"translation": "Betrieblicher Unterricht"
},
{
"id": "professional_school",
"translation": "Berufsschule"
},
{
"id": "proof_of_education",
"translation": "Ausbildungsnachweis Nr. {{.Count}}"
},
{
"id": "trainee",
"translation": "Auszubildende/r"
},
{
"id": "time_period",
"translation": "Zeitraum"
}
]
1 change: 1 addition & 0 deletions export/latex/localization/de-de.untranslated.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
54 changes: 54 additions & 0 deletions export/latex/localization/en-us.all.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[
{
"id": "calendar_week",
"translation": "Calendar week"
},
{
"id": "calendar_week_short",
"translation": "CW"
},
{
"id": "department",
"translation": "Department"
},
{
"id": "instructor",
"translation": "Instructor"
},
{
"id": "legal_representative",
"translation": "Legal representative"
},
{
"id": "name",
"translation": "Name"
},
{
"id": "no_school_periods_this_week",
"translation": "No school periods this week."
},
{
"id": "operational_activities",
"translation": "Operational activities"
},
{
"id": "operational_instruction",
"translation": "Operational instruction"
},
{
"id": "professional_school",
"translation": "Professional school"
},
{
"id": "proof_of_education",
"translation": "Proof of Education No. {{.Count}}"
},
{
"id": "trainee",
"translation": "Trainee"
},
{
"id": "time_period",
"translation": "Time period"
}
]
1 change: 1 addition & 0 deletions export/latex/localization/en-us.untranslated.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Loading

0 comments on commit fa26623

Please sign in to comment.