{"id":18343460,"url":"https://github.com/cosimo/libvmod-i18n","last_synced_at":"2025-10-27T00:48:35.262Z","repository":{"id":66959038,"uuid":"51603913","full_name":"cosimo/libvmod-i18n","owner":"cosimo","description":"Varnish VMOD to parse/normalize Accept-Language browser headers","archived":false,"fork":false,"pushed_at":"2016-02-15T15:14:15.000Z","size":20,"stargazers_count":7,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"3.0","last_synced_at":"2025-03-21T19:05:11.777Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cosimo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-12T17:18:30.000Z","updated_at":"2021-07-08T13:40:01.000Z","dependencies_parsed_at":"2023-05-02T10:44:24.139Z","dependency_job_id":null,"html_url":"https://github.com/cosimo/libvmod-i18n","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosimo%2Flibvmod-i18n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosimo%2Flibvmod-i18n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosimo%2Flibvmod-i18n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cosimo%2Flibvmod-i18n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cosimo","download_url":"https://codeload.github.com/cosimo/libvmod-i18n/tar.gz/refs/heads/3.0","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247450532,"owners_count":20940934,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T20:36:09.031Z","updated_at":"2025-10-27T00:48:35.195Z","avatar_url":"https://github.com/cosimo.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"libvmod-i18n\n============\n\n[![Build Status](https://travis-ci.org/cosimo/libvmod-i18n.svg?branch=master)](https://travis-ci.org/cosimo/libvmod-i18n)\n\nNormalize and filter all the incoming requests' Accept-Language headers and\nreduce them to just the languages your website or service supports.\n\nThis vmod is the newer, shinier version of my [varnish-accept-language VCL\nmodule](https://github.com/cosimo/varnish-accept-language), which should be\nconsidered deprecated.\n\n\nWhat is this again?\n-------------------\n\nThis is a software module (vmod) you use together with the Varnish HTTP reverse\nproxy, when your website is localized in different languages, and you want to\nbe able to cache objects according to the language.\n\n**WARNING**\n\nThis module consists of C code. Your Varnish might explode. YMMV.\nDon't use it in production if you don't know what you're doing.\nWe and many other people are using it in production, but we _don't_ know what\nwe're doing :).\n\n\nWhy would you want this?\n------------------------\n\nLet's say your website supports English and Japanese languages.\n\nYour client browsers will send every possible Accept-Language header on Earth.\nIf you enable \"Vary: Accept-Language\" on Varnish or on your backends, the cache\nhit ratio will rapidly drop, because of the huge variations in\nAccept-Language string contents.\n\nWith this vmod, you can rewrite the Accept-Language header to just \"en\" or\n\"ja\", depending on your client settings. If no good match occurs, for example\nif your clients are asking for a language that is not English nor Japanese,\nyou can still select a default language for your website.\n\nIf you choose to to rewrite the original Accept-Language header,\nthis language normalization will be completely transparent to your backend.\n\n\nModule interface\n----------------\n\n\n== `i18n.match(STRING)`\n\nReads the Accept-Language header (or any other string passed to it), and\ncarries out Accept-Language parsing. The (language, q) pairs found are\nsorted by priority (q), and the first language that is also declared as\nsupported (through the `i18n.supported_languages()` call, gets returned.\n\nIf no languages are supported, all languages are assumed to be supported.\n\nIf no default language has been specified, English is assumed (\"en\").\n\nExample:\n\n    sub vcl_recv {\n        set req.http.Lang = i18n.match(req.http.Accept-Language);\n    }\n\n== `i18n.default_language(STRING)`\n\nTypically used in `vcl_init()`, to specify which language should be assumed\nas default when Accept-Language is either empty, or none of the languages in\nit are supported.\n\nIf no default language is specified, English is assumed (\"en\").\n\n== `is_supported(STRING)`\n\nReturns 0 if the specified language is supported, otherwise 1.\n\n== `supported_languages(STRING)`\n\nTypically used in `vcl_init()`, to specify which languages your site or service\nsupports. Note that this is a string, not a list, so you need to specify the\nlist of supported languages as a colon-separated.\n\nExample:\n\n    sub vcl_init {\n        i18n.supported_languages(\"de:fr:fr-CA:en:hi:it:ja\");\n    }\n\n== `parse(STRING, STRING)`\n\nInternal function that performs the Accept-Language string parsing (first\nparameter). The second parameter is the default language to be returned if\nno language is supported or Accept-Language is empty.\n\nIf you're not sure about using this function, it's because you shouldn't be\nusing it. Use `match()` instead.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcosimo%2Flibvmod-i18n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcosimo%2Flibvmod-i18n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcosimo%2Flibvmod-i18n/lists"}