Comments (3)
Hey!
I added two new helper functions:
- GetDefaultLanguageValue
- GetLanguageValueByID
to get languages by ID or the default language text
from go-prestashop-api.
I'm now using for+range func to get the text with one language,
I think this is a simple way to do,
type ProductLanguageData struct {
Language *[]ProductLanguage xml:"language,omitempty" json:"language,omitempty"
//Text string, add for language hooks
}
// utils
func StrToInt(s string) int {
val, err := strconv.Atoi(s)
if err != nil {
return 0
}
return val
}
func GetLanguageText(idLang int, Language *[]prestashop.ProductLanguage) string {
if Language != nil {
for _, v := range *Language {
if utils.StrToInt(v.ID) == idLang {
return v.Text
}
}
}
return ""
}
If I put some id lang value in the query params, then the response will add hook to return what I need,
then I can get this in everywhere
p.Name.Language for range .Text ==> p.Name.Text
from go-prestashop-api.
Hello!
Thanks! I will add some helper functions like this to get product names by language ID + default languages. (I will consider the first language as the default language)
from go-prestashop-api.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-prestashop-api.