Skip to content

Commit

Permalink
fix: getLang fallback
Browse files Browse the repository at this point in the history
Fixes #398
  • Loading branch information
arildm committed Oct 1, 2024
1 parent ab8cf18 commit 213214c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- In the corpus selector, an empty folder would add 1 to the parent folder's corpus count
- Searching by pressing Enter in Simple search is broken [#394](https://github.com/spraakbanken/korp-frontend/issues/394)
- Barcode (aka hitsPicture) sometimes missing from KWIC tab [#395](https://github.com/spraakbanken/korp-frontend/issues/395)
- Error when loading with restricted corpora selected [#398](https://github.com/spraakbanken/korp-frontend/issues/398)

## [9.7.1] - 2024-09-18

Expand Down
11 changes: 8 additions & 3 deletions app/scripts/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
/** @format */
import isObject from "lodash/isObject"
import settings from "@/settings"
import { getService } from "@/util"
import type { LangLocMap, LangString, LocLangMap, LocMap } from "@/i18n/types"
import { getService, getUrlHash } from "@/util"
import type { LangString, LocLangMap, LocMap } from "@/i18n/types"

/** Get the current UI language. */
export function getLang(): string {
return getService("$rootScope").lang || settings.default_language
// If called during bootstrap, the Root Scope service may not be ready
try {
return getService("$rootScope").lang || settings.default_language
} catch (e) {
return getUrlHash("lang") || settings.default_language
}
}

/**
Expand Down
3 changes: 1 addition & 2 deletions app/scripts/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import _ from "lodash"
import angular, { IControllerService, IHttpService, type IRequestConfig, type IScope } from "angular"
import settings from "@/settings"
import { getLang, loc, locObj } from "@/i18n"
import { LangMap, LangString } from "./i18n/types"
import { LangString } from "./i18n/types"
import { RootScope } from "./root-scope.types"
import { JQueryExtended, JQueryStaticExtended } from "./jquery.types"
import { HashParams, LocationService, UrlParams } from "./urlparams"
import { Attribute } from "./settings/config.types"
import { AttributeOption } from "./corpus_listing"

/** Use html`<div>html here</div>` to enable formatting template strings with Prettier. */
Expand Down

0 comments on commit 213214c

Please sign in to comment.