Skip to content

Commit

Permalink
Removing _contextualLocale and runWithLocale
Browse files Browse the repository at this point in the history
  • Loading branch information
zendranm committed Mar 7, 2023
1 parent 5c9f1c0 commit 53c8b8f
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 14 deletions.
8 changes: 1 addition & 7 deletions source/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export interface SetLocaleOptions extends LoadLocaleOptions {
}

const i18n = {
_contextualLocale: new Meteor.EnvironmentVariable<string | undefined>(),
_deps: new Tracker.Dependency(),
_emitChange(locale?: string) {
i18n._events.emit('changeLocale', locale ?? i18n._locale);
Expand Down Expand Up @@ -201,9 +200,7 @@ const i18n = {
return Object.keys(i18n._translations);
},
getLocale() {
return (
i18n._contextualLocale.get() ?? i18n._locale ?? i18n.options.defaultLocale
);
return i18n._locale ?? i18n.options.defaultLocale;
},
getTranslation(...args: unknown[]) {
const maybeOptions = args[args.length - 1];
Expand Down Expand Up @@ -266,9 +263,6 @@ const i18n = {
sameLocaleOnServerConnection: true,
translationsHeaders: { 'Cache-Control': 'max-age=2628000' },
} as Options,
runWithLocale<T>(locale = '', fn: () => T): T {
return i18n._contextualLocale.withValue(i18n.normalize(locale), fn);
},
setLocale(locale: string, options?: SetLocaleOptions) {
const normalizedLocale = i18n.normalize(locale);
if (!normalizedLocale) {
Expand Down
5 changes: 0 additions & 5 deletions source/server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { NextHandleFunction } from 'connect';
import Fibers from 'fibers';
import { dump, FAILSAFE_SCHEMA } from 'js-yaml';
import { Match, check } from 'meteor/check';
import { DDP } from 'meteor/ddp';
Expand All @@ -14,10 +13,6 @@ import { JSONObject, set } from './utils';

i18n.setOptions({ hostUrl: Meteor.absoluteUrl() });

const _get = i18n._contextualLocale.get.bind(i18n._contextualLocale);
i18n._contextualLocale.get = () =>
Fibers.current ? _get() ?? i18n._getConnectionLocale() : undefined;

function getDiff(locale: string, diffWith?: string) {
const diff: JSONObject = {};
const diffKeys = i18n.getAllKeysForLocale(diffWith);
Expand Down
2 changes: 0 additions & 2 deletions types/common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export interface SetLocaleOptions extends LoadLocaleOptions {
noDownload?: boolean;
}
declare const i18n: {
_contextualLocale: Meteor.EnvironmentVariable<string | undefined>;
_deps: Tracker.Dependency;
_emitChange(locale?: string | undefined): void;
_events: EventEmitter;
Expand Down Expand Up @@ -95,7 +94,6 @@ declare const i18n: {
onChangeLocale(fn: (locale: string) => void): void;
onceChangeLocale(fn: (locale: string) => void): void;
options: Options;
runWithLocale<T>(locale: string | undefined, fn: () => T): T;
setLocale(
locale: string,
options?: SetLocaleOptions | undefined,
Expand Down

0 comments on commit 53c8b8f

Please sign in to comment.