关于网站语言设置的问题
例如:
我有3个网页连接超链接(从page01 - > page02 / page03和返回)。我想更改第1页上的语言。(即使用选择按钮)。
语言更改后,所有3个页面都应以新语言显示内容。
服务器是否可以发送一种语言文件,每个网站都可以搜索语言标签?
答案 0 :(得分:0)
为不同语言提供不同的网址。
/en-us/page1
/en-us/page2
/en-us/page3
/es-es/page1
/es-es/page2
/es-es/page3
然后只使用它们之间的相对URL。
<ul>
<li> <a href="page1">Page 1</a> </li>
<li> <a href="page2">Page 2</a> </li>
<li> <a href="page3">Page 3</a> </li>
</ul>
<a href="../es-es/page1" lang="es-es" hreflang="es-es">español</a>
答案 1 :(得分:0)
static func decrementIventory(completed: @escaping (Bool) -> (), productId: String) throws {
print("Product.decrementIventory() : started")
let context = CoreData.databaseContext
let request: NSFetchRequest<Product> = Product.fetchRequest()
request.predicate = NSPredicate(format: "productId == %@", productId)
do {
let fetch = try context.fetch(request)
print("Product.decrementIventory() : fetching product")
if fetch.count > 0 {
for value in fetch {
// if value.productId == productId {
if #available(iOS 10.0, *) {
let newAvailableQuantity = Int(value.availableQuantity!)! - 1
let newSoldQuantity = Int(value.soldQuantity!)! + 1
value.setValue(String(describing: newAvailableQuantity) , forKey: "availableQuantity")
value.setValue(String(describing: newSoldQuantity), forKey: "soldQuantity")
let ref = Database.database().reference()
ref.child("Continent").child("Europe").child("Country").child("\(UserDetails.country!)").child("Region").child(UserDetails.region!).child("City").child(UserDetails.city!).child("Catalog").child("\(productId)").child("Available Quantity").setValue(String(describing: newAvailableQuantity))
ref.child("Continent").child("Europe").child("Country").child("\(UserDetails.country!)").child("Region").child(UserDetails.region!).child("City").child(UserDetails.city!).child("Catalog").child("\(productId)").child("Sold Quantity").setValue(String(describing: newSoldQuantity))
} else {
// Fallback on earlier versions
let newAvailableQuantity = Int(value.availableQuantity!)! - 1
let newSoldQuantity = Int(value.soldQuantity!)! + 1
value.setValue(String(describing: newAvailableQuantity) , forKey: "availableQuantity")
value.setValue(String(describing: newSoldQuantity), forKey: "soldQuantity")
let ref = Database.database().reference()
ref.child("Continent").child("Europe").child("Country").child("\(UserDetails.country!)").child("Region").child(UserDetails.region!).child("City").child(UserDetails.city!).child("Catalog").child("\(productId)").child("Available Quantity").setValue(String(describing: newAvailableQuantity))
ref.child("Continent").child("Europe").child("Country").child("\(UserDetails.country!)").child("Region").child(UserDetails.region!).child("City").child(UserDetails.city!).child("Catalog").child("\(productId)").child("Sold Quantity").setValue(String(describing: newSoldQuantity))
}
// }
}
}
} catch {
print("Product.decrementIventory() : Error in fetching a product : \(error)")
}
do {
try context.save()
print("Product.decrementIventory() : modified product is saved to Core Data")
// setting completion for decrementIventory() here causes inconsistency in Firebase, so we set completion for decrementIventory() in Firebase.uploadProduct completed scope
completed(true)
} catch {
print("Product.decrementIventory() : Error saving modified product to Core Data : \(error)")
}
}
这使用Google翻译显示了语言的下拉列表。
参考https://www.w3schools.com/howto/howto_google_translate.asp