Skip to content

Commit d296a01

Browse files
authored
Migrate hardcoded strings to i18n vars (swiftlang#523)
Resolves: rdar://102139999 rdar://104876012
1 parent 71f4bc8 commit d296a01

File tree

177 files changed

+1841
-592
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

177 files changed

+1841
-592
lines changed

app/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
-->
1010

1111
<!DOCTYPE html>
12-
<html lang="en">
12+
<html lang="en-US">
1313
<head>
1414
<meta charset="utf-8">
1515
<meta http-equiv="X-UA-Compatible" content="IE=edge">

app/main.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* This source file is part of the Swift.org open source project
33
*
4-
* Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
* Copyright (c) 2021-2023 Apple Inc. and the Swift project authors
55
* Licensed under Apache License v2.0 with Runtime Library Exception
66
*
77
* See https://swift.org/LICENSE.txt for license information
@@ -10,15 +10,19 @@
1010

1111
import '../webpack-asset-path';
1212
import Vue from 'vue';
13+
import VueI18n from 'vue-i18n';
1314
import Router from 'vue-router';
1415
import App from '@/App.vue';
1516
import SwiftDocCRenderPlugin from '@/setup-utils/SwiftDocCRenderPlugin';
1617
import SwiftDocCRenderRouter from '@/setup-utils/SwiftDocCRenderRouter';
18+
import SwiftDocCRenderi18n from '@/setup-utils/SwiftDocCRenderi18n';
1719

1820
Vue.use(SwiftDocCRenderPlugin);
1921
Vue.use(Router);
22+
Vue.use(VueI18n);
2023

2124
new Vue({
2225
router: SwiftDocCRenderRouter(),
2326
render: h => h(App),
27+
i18n: SwiftDocCRenderi18n(),
2428
}).$mount('#app');

index.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* This source file is part of the Swift.org open source project
33
*
4-
* Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
* Copyright (c) 2021-2023 Apple Inc. and the Swift project authors
55
* Licensed under Apache License v2.0 with Runtime Library Exception
66
*
77
* See https://swift.org/LICENSE.txt for license information
@@ -10,6 +10,9 @@
1010

1111
import SwiftDocCRenderPlugin from './src/setup-utils/SwiftDocCRenderPlugin';
1212
import createRouterInstance from './src/setup-utils/SwiftDocCRenderRouter';
13+
import createi18nInstance from './src/setup-utils/SwiftDocCRenderi18n';
1314
import defaultRoutes from './src/routes';
1415

15-
export { SwiftDocCRenderPlugin, createRouterInstance, defaultRoutes };
16+
export {
17+
SwiftDocCRenderPlugin, createRouterInstance, createi18nInstance, defaultRoutes,
18+
};

jest.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* This source file is part of the Swift.org open source project
33
*
4-
* Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
* Copyright (c) 2021-2023 Apple Inc. and the Swift project authors
55
* Licensed under Apache License v2.0 with Runtime Library Exception
66
*
77
* See https://swift.org/LICENSE.txt for license information
@@ -16,4 +16,5 @@ module.exports = {
1616
'^theme/(.*)$': '<rootDir>/src/$1',
1717
},
1818
testEnvironment: 'jest-environment-jsdom',
19+
setupFiles: ['./tests/unit/config.js'],
1920
};

package-lock.json

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"highlight.js": "^11.3.1",
2727
"intersection-observer": "0.12.0",
2828
"portal-vue": "2.1.7",
29+
"vue-i18n": "^8.28.2",
2930
"vue-virtual-scroller": "^1.1.2",
3031
"webpack-theme-resolver-plugin": "3.0.0"
3132
},

src/App.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!--
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2023 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -14,7 +14,7 @@
1414
:class="{ fromkeyboard: fromKeyboard, hascustomheader: hasCustomHeader }"
1515
>
1616
<div :id="AppTopID" />
17-
<a href="#main" id="skip-nav">Skip Navigation</a>
17+
<a href="#main" id="skip-nav">{{ $t('accessibility.skip-navigation') }}</a>
1818
<InitialLoadingPlaceholder />
1919
<slot name="header" :isTargetIDE="isTargetIDE">
2020
<!-- Render the custom header by default, if there is no content in the `header` slot -->
@@ -75,7 +75,7 @@ export default {
7575
// preference to determine if "Light" or "Dark" colors should be used.
7676
// Otherwise, if "Light" or "Dark" has been explicitly chosen, that choice
7777
// should be used directly.
78-
objectToCustomProperties(themeSettings.theme, (preferredColorScheme === ColorScheme.auto.value
78+
objectToCustomProperties(themeSettings.theme, (preferredColorScheme === ColorScheme.auto
7979
? currentColorScheme
8080
: preferredColorScheme
8181
))
@@ -170,7 +170,7 @@ export default {
170170
},
171171
onColorSchemePreferenceChange({ matches }) {
172172
const scheme = matches ? ColorScheme.dark : ColorScheme.light;
173-
AppStore.setSystemColorScheme(scheme.value);
173+
AppStore.setSystemColorScheme(scheme);
174174
},
175175
attachStylesToRoot(CSSCustomProperties) {
176176
const root = document.body;

src/components/Badge.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!--
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021-2022 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2023 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -10,14 +10,14 @@
1010

1111
<template>
1212
<span class="badge" :class="{ [`badge-${variant}`]: variant }" role="presentation">
13-
<slot>{{ text }}</slot>
13+
<slot>{{ text ? $t(text) : '' }}</slot>
1414
</span>
1515
</template>
1616

1717
<script>
1818
const VARIANT_TEXT = {
19-
beta: 'Beta',
20-
deprecated: 'Deprecated',
19+
beta: 'aside-kind.beta',
20+
deprecated: 'aside-kind.deprecated',
2121
};
2222

2323
export default {

src/components/ColorSchemeToggle.vue

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!--
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2023 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -10,21 +10,21 @@
1010

1111
<template>
1212
<div
13-
aria-label="Select a color scheme preference"
13+
:aria-label="$t('color-scheme.select')"
1414
class="color-scheme-toggle"
1515
role="radiogroup"
1616
>
1717
<label
1818
v-for="option in options"
19-
:key="option.value"
19+
:key="option"
2020
>
2121
<input
2222
type="radio"
2323
@input="setPreferredColorScheme"
24-
:checked="option.value == preferredColorScheme"
25-
:value="option.value"
24+
:checked="option == preferredColorScheme"
25+
:value="option"
2626
/>
27-
<div class="text">{{option.label}}</div>
27+
<div class="text">{{ $t(`color-scheme.${option}`) }}</div>
2828
</label>
2929
</div>
3030
</template>

src/components/ContentNode/Aside.vue

+2-9
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<template>
1212
<aside :class="kind" :aria-label="kind">
13-
<p class="label">{{ label }}</p>
13+
<p class="label">{{ name || $t(label) }}</p>
1414
<slot />
1515
</aside>
1616
</template>
@@ -39,14 +39,7 @@ export default {
3939
},
4040
},
4141
computed: {
42-
label: ({ kind, name }) => name || ({
43-
[Kind.deprecated]: 'Deprecated',
44-
[Kind.experiment]: 'Experiment',
45-
[Kind.important]: 'Important',
46-
[Kind.note]: 'Note',
47-
[Kind.tip]: 'Tip',
48-
[Kind.warning]: 'Warning',
49-
}[kind]),
42+
label: ({ kind }) => `aside-kind.${kind}`,
5043
},
5144
};
5245
</script>

src/components/ContentNode/EndpointExample.vue

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!--
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2023 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -13,8 +13,8 @@
1313
<Column class="example-code">
1414
<slot />
1515
<Tabnav v-model="currentTab">
16-
<TabnavItem :value="Tab.request">{{ Tab.request }}</TabnavItem>
17-
<TabnavItem :value="Tab.response">{{ Tab.response }}</TabnavItem>
16+
<TabnavItem :value="Tab.request">{{ $t('tab.request') }}</TabnavItem>
17+
<TabnavItem :value="Tab.response">{{ $t('tab.response') }}</TabnavItem>
1818
</Tabnav>
1919
<div class="output">
2020
<div v-if="isCurrent(Tab.request)" class="code">
@@ -35,11 +35,11 @@
3535
<div class="controls" v-if="isCollapsible">
3636
<a v-if="isCollapsed" href="#" class="toggle" @click.prevent="showMore">
3737
<InlinePlusCircleSolidIcon class="control-icon icon-inline" />
38-
More
38+
{{ $t('more') }}
3939
</a>
4040
<a v-else href="#" class="toggle" @click.prevent="showLess">
4141
<InlineMinusCircleSolidIcon class="control-icon icon-inline" />
42-
Less
42+
{{ $t('less') }}
4343
</a>
4444
</div>
4545
</Column>
+16-15
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
<!--
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2023 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
88
See https://swift.org/CONTRIBUTORS.txt for Swift project authors
99
-->
1010

1111
<template>
12-
<s>
13-
<slot />
12+
<s
13+
:data-before-text="$t('accessibility.strike.start')"
14+
:data-after-text="$t('accessibility.strike.end')">
15+
<slot />
1416
</s>
1517
</template>
1618

@@ -19,19 +21,18 @@ export default {
1921
name: 'StrikeThrough',
2022
};
2123
</script>
22-
23-
<style scoped lang='scss'>
24+
<style scoped lang="scss">
2425
@import 'docc-render/styles/_core.scss';
2526

26-
s::before, s::after {
27-
@include visuallyhidden()
28-
}
29-
30-
s::before {
31-
content: " [start of stricken text] ";
32-
}
33-
34-
s::after {
35-
content: " [end of stricken text] ";
27+
s {
28+
&::before {
29+
content: attr(data-before-text);
30+
}
31+
&::after {
32+
content: attr(data-after-text);
33+
}
34+
&::before, &::after {
35+
@include visuallyhidden()
36+
}
3637
}
3738
</style>

src/components/DocumentationTopic.vue

+4-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
<BetaLegalText v-if="!isTargetIDE && hasBetaContent" />
137137
</main>
138138
<div aria-live="polite" class="visuallyhidden">
139-
Current page is {{ pageTitle }}
139+
{{ $t('documentation.current-page', { title: pageTitle }) }}
140140
</div>
141141
</div>
142142
</template>
@@ -468,7 +468,9 @@ export default {
468468
interfaceLanguage === Language.objectiveC.key.api
469469
? normalizedObjcPath : normalizedSwiftPath
470470
),
471-
tagName: ({ isSymbolDeprecated }) => (isSymbolDeprecated ? 'Deprecated' : 'Beta'),
471+
tagName() {
472+
return this.isSymbolDeprecated ? this.$t('aside-kind.deprecated') : this.$t('aside-kind.beta');
473+
},
472474
/**
473475
* Finds the page icon in the `pageImages` array
474476
* @param {Array} pageImages

src/components/DocumentationTopic/BetaLegalText.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!--
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021-2022 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2023 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -13,10 +13,10 @@
1313
<div class="betainfo-container">
1414
<GridRow>
1515
<GridColumn :span="{ large: 12 }">
16-
<p class="betainfo-label">Beta Software</p>
16+
<p class="betainfo-label">{{ $t('metadata.beta.software') }}</p>
1717
<div class="betainfo-content">
1818
<slot name="content">
19-
<p>This documentation refers to beta software and may be changed.</p>
19+
<p>{{ $t('metadata.beta.legal') }}</p>
2020
</slot>
2121
</div>
2222
<slot name="after" />

src/components/DocumentationTopic/DefaultImplementations.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!--
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2023 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -11,7 +11,7 @@
1111
<template>
1212
<TopicsTable
1313
:anchor="contentSectionData.anchor"
14-
:title="contentSectionData.title"
14+
:title="$t(contentSectionData.title)"
1515
:isSymbolDeprecated="isSymbolDeprecated"
1616
:isSymbolBeta="isSymbolBeta"
1717
:sections="sections"

src/components/DocumentationTopic/Description/RequirementMetadata.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!--
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2023 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -11,9 +11,9 @@
1111
<template functional>
1212
<!-- because the component is functional we must mannually pass the classes -->
1313
<p class="requirement-metadata" :class="data.staticClass">
14-
<strong>Required.</strong>
14+
<strong>{{ parent.$t('required') }}</strong>
1515
<template v-if="props.defaultImplementationsCount">
16-
Default implementation{{ props.defaultImplementationsCount > 1 ? 's' : '' }} provided.
16+
{{ parent.$tc('metadata.default-implementation', props.defaultImplementationsCount) }}
1717
</template>
1818
</p>
1919
</template>

0 commit comments

Comments
 (0)