-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include languages into manifest #208
Comments
Could you elaborate the use case a bit? The lang attribute (as defined by the HTML spec) can be used on any HTML element. Commonly this is applied to the html element (e.g. <html lang="en">). |
One of the use case could be a multilingual webapp, with an entry point by language. The user agents could load the entry point regarding the language of the user. {
"languages" : {
"en" : {
"url" : "http://domain.tld/en/index.html"
},
"fr" : {
"url" : "http://domain.tld/fr/index.html"
}
}
} |
@krampstudio Thanks, that clarifies the use case. @marcoscaceres Perhaps you could share your learnings with the Widgets language tag? |
I think we want to see how people solve this in the wild first. Most sites allow the user to set the language using the apps UI. Like this: And this: So, changing language, one can just change the function updateLang(langCode){
document.querySelector("link[rel=manifest]").href = "manifest.php?lang=" + langCode;
document.querySelector("link[rel=manifest]").hreflang = langCode;
} Or, |
Marking as feature request - just a note that the original spec included a |
A great little alternative i18n model over in #211. I like it! 👍 |
Closing this bug in favor or #211. |
As I mentioned in #211 (link to comment), a canonical list of available languages is great to have for client-side language negotiation. In order to negotiate languages, three pieces of information are needed: the list of all languages the app is available in, the list of languages the user speaks, in order of preference, and the default language of the app in case there is no intersection between the first two sets. A dedicated property could look like this:
The default locale can but it doesn't have to be specified in the In certain scenarios it would be useful if the array could be changed to a dict specifying versions of available languages. Together with @zbraniecki, I have been prototyping a client-side service in Gecko to provide localizations externally to the app. The goal is to be able to add more languages and update localizations independent of the app. We call it the language package service. Having the available languages versioned allows the service to be smart about localizations it can provide. If no versions are given (like in the example above), the service will assume that all localizations bundled with the app are up to date. In the following example, French is up-to-date with the version of the app (it has all the new strings introduced in this version).
An alternative notation could look like the following (I'm not sure how stable
|
Why not only "languages"? the order of the langeages-array is given so the first is the default-language:
simple and easy |
If the language negotiation is going to be done client-side by JS, then it doesn't belong in the manifest. The things in the manifest should only be used at the UA level, not at the JS level (though the effects of the manifest are then reflected in the browsing environment through JS or CSS as appropriate). |
using the ordering so the first is the default seems reasonable in practice. if there are different versions for different languages, we should apply the same model (as in issue #211 ) to the version property as to other stuff, no? e.g. (using the implication that Russian is the default version) |
Hmm. Do we need a property for languages, or can we just extract that from the manifest by looking at what it mentions and taking the union? (We also don't have, and probably don't need, a way of saying whether a given localisation is complete.) |
@marcoscaceres You're right, I used a mental shortcut. What I meant was that the information about available languages is useful for client-side language negotiation. The W3C manifest could be—in my mind—a good place to store this information. It would need to be parsed and exposed to client-side JS by the UA in form of an API, e.g. Such One way to get around this would be to allow for certain information to be inlined into the document's source HTML, much like CSS allows for inline style definitions. Currently in Firefox OS, for instance, we found that it was good for performance to inline the languages data in form of Do you know if there are any plans to provide any kind of inlining mechanism for W3C manifests? |
( |
@chaals Unfortunately, object keys are not guaranteed to have their keys order preserved. We need a separate key for that. |
@stasm the problem is that there is no guarantee that the manifest will be downloaded at all - ever. It's a low priority resource and some user agents may opt to not download it until it is actually needed, such as when the user takes explicit action to "install" the application (thus it's deliberately unreliable). Even if we include localized content (e.g., name), that content would only be applicable at install time. It also puts the developer into a race condition, having to wait for the manifest to be downloaded an applied: even in the best case, this happens after the load event has fired (again, by design). For this reason, this resource is not appropriate, IMO, to use for localizing applications. A better approach would be to use a library and dynamically d/l localized strings and content as needed: or just include the relevant information inline via script tags (or XHR'ing a different JSON document specifically for localization purposes). Does that make sense? |
D'uh. Right :S 27.10.2014, 16:34, "Zibi Braniecki" notifications@github.com:
Charles McCathie Nevile - web standards - CTO Office, Yandex |
@marcoscaceres Thank you for providing more context about when the manifest could be downloaded—and if at all. I can see now why a user-land localization library should not try to get rely the information about the available and the default languages directly from the manifest. There is a use-case which I think still justifies storing this information in the manifest instead of in a separate resource which would be XHR'ed by the localization library. We are currently investigating language packages (or language bundles) for Firefox OS apps which would allow extending language coverage of other apps. During an installation of an app, the information about the available languages carried in the manifest would be stored by the user agent. Then, a language bundle could modify that saved information by adding more languages to the list. A user-land localization library would then need an API exposed by the user agent to retrieve the list of all available languages for a given app. (In Firefox OS, that could be a method of the mozApps API). You can find more information in the spec draft that I'm working on. |
I am just writing some good practices based on the API surface area that we ahve today (cc @mounirlamouri and @marcosc) and I was thinking: Do we need to actually do anything at all? As a developer I have full control over what is returned to the UA from my server. I can look at the languages accepted in the fetch for the manifest, and return a localized one if needs be, I could also pass in a query string value if I really really wanted to. We can also mitigate some of the caching issues when the user changes system language by Vary: Accept-Language The open question is, if keeping the original language on the app (such as when it is on the homescreen) is a massive problem if the user has changed languages after installing? My experience managing languages in Chrome Apps makes me want to avoid adding any complexity or bloat to the manifest and I feel that we have a "reasonable" story as of today for serving the user the correct manifest at time of install. |
I think the web platform already get a notification when the system language changes. Potentially we could treat that as a good time to mark the manifest info as dirty? |
That might be the case, if manifests would be used and accessed only at the time of installation. What about other use cases though, like e.g. app catalogs, app search results, etc.? For these it might be really useful to be able to index what languages an app supports. |
@kenchris wrote:
There is
You don't need to treat it as dirty. One can then update link's href like I proposed here: #208 (comment) I'd like to echo what @PaulKinlan + I think we need to get a bit of implementation experience to see what issues come up as this gets rolled out over the next year. @skddc, I assume indexing of supported languages would work exactly as it does today: by actually providing the app in those languages, rather than claiming an applications supports some particular set of language (i.e., crawlers index and make decisions on actual content, not on metadata claims which are easy to forge or get wrong). |
I'd like to close this issue to allow us to roll out an initial version of the spec. We can then begin gathering feedback and seeing how people adapt manifests to different languages in the wild. We have a good set of possible solutions, which we can easily add to the spec and implementations once we see what happens on the web. |
It would be also nice to be able to know which languages the web app supports.
The text was updated successfully, but these errors were encountered: