2020-07-04 12:54:35 +02:00
|
|
|
/*
|
|
|
|
|
|
|
|
Package i18n contains PhotoPrism status and error message strings.
|
|
|
|
|
2022-02-20 17:36:51 +01:00
|
|
|
Copyright (c) 2018 - 2022 Michael Mayer <hello@photoprism.app>
|
2020-07-04 12:54:35 +02:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as published
|
|
|
|
by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
2020-09-21 02:48:22 +02:00
|
|
|
PhotoPrism® is a registered trademark of Michael Mayer. You may use it as required
|
2020-07-04 12:54:35 +02:00
|
|
|
to describe our software, run your own server, for educational purposes, but not for
|
|
|
|
offering commercial goods, products, or services without prior written permission.
|
|
|
|
In other words, please ask.
|
|
|
|
|
|
|
|
Feel free to send an e-mail to hello@photoprism.org if you have questions,
|
|
|
|
want to support our work, or just want to say hello.
|
|
|
|
|
|
|
|
Additional information can be found in our Developer Guide:
|
2021-12-12 20:48:05 +01:00
|
|
|
https://docs.photoprism.app/developer-guide/
|
2020-07-04 12:54:35 +02:00
|
|
|
|
|
|
|
*/
|
|
|
|
package i18n
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
2020-07-15 01:26:54 +02:00
|
|
|
|
|
|
|
"github.com/leonelquinteros/gotext"
|
2020-07-04 12:54:35 +02:00
|
|
|
)
|
|
|
|
|
2020-07-15 01:26:54 +02:00
|
|
|
//go:generate xgettext --no-wrap --language=c --from-code=UTF-8 --output=../../assets/locales/messages.pot messages.go
|
|
|
|
|
2020-07-04 12:54:35 +02:00
|
|
|
type Message int
|
|
|
|
type MessageMap map[Message]string
|
|
|
|
|
2020-07-15 01:26:54 +02:00
|
|
|
func gettext(s string) string {
|
|
|
|
return gotext.Get(s)
|
2020-07-04 12:54:35 +02:00
|
|
|
}
|
|
|
|
|
2020-07-15 01:26:54 +02:00
|
|
|
func Msg(id Message, params ...interface{}) string {
|
|
|
|
msg := gotext.Get(Messages[id])
|
2020-07-04 12:54:35 +02:00
|
|
|
|
|
|
|
if strings.Contains(msg, "%") {
|
|
|
|
msg = fmt.Sprintf(msg, params...)
|
|
|
|
}
|
|
|
|
|
|
|
|
return msg
|
|
|
|
}
|
|
|
|
|
|
|
|
func Error(id Message, params ...interface{}) error {
|
2021-09-17 15:52:25 +02:00
|
|
|
return errors.New(strings.ToLower(Msg(id, params...)))
|
2020-07-04 12:54:35 +02:00
|
|
|
}
|