Skip to content

Export FluentResource from fluent #286

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

Merged
merged 2 commits into from
Sep 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions fluent/src/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import FluentResource from "./resource";
* context's language. See the documentation of the Fluent syntax for more
* information.
*/
export class FluentBundle {
export default class FluentBundle {

/**
* Create an instance of `FluentBundle`.
Expand Down Expand Up @@ -122,10 +122,10 @@ export class FluentBundle {
/**
* Add a translation resource to the context.
*
* The translation resource must be a proper FluentResource
* parsed by `FluentBundle.parseResource`.
* The translation resource must be an instance of FluentResource,
* e.g. parsed by `FluentResource.fromString`.
*
* let res = FluentBundle.parseResource("foo = Foo");
* let res = FluentResource.fromString("foo = Foo");
* bundle.addResource(res);
* bundle.getMessage('foo');
*
Expand Down
5 changes: 2 additions & 3 deletions fluent/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
*
*/

export { default as _parse } from "./parser";

export { FluentBundle } from "./context";
export { default as FluentBundle } from "./context";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll rename context.js to bundle.js in a follow-up commit (without a separate PR).

export { default as FluentResource } from "./resource";
export { FluentType, FluentNumber, FluentDateTime } from "./types";

export { ftl } from "./util";
2 changes: 1 addition & 1 deletion fluent/test/arguments_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import assert from 'assert';

import { FluentBundle } from '../src/context';
import FluentBundle from '../src/context';
import { FluentType } from '../src/types';
import { ftl } from '../src/util';

Expand Down
2 changes: 1 addition & 1 deletion fluent/test/attributes_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import assert from 'assert';

import { FluentBundle } from '../src/context';
import FluentBundle from '../src/context';
import { ftl } from '../src/util';

suite('Attributes', function() {
Expand Down
2 changes: 1 addition & 1 deletion fluent/test/bomb_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import assert from 'assert';

import { FluentBundle } from '../src/context';
import FluentBundle from '../src/context';
import { ftl } from '../src/util';

suite('Reference bombs', function() {
Expand Down
2 changes: 1 addition & 1 deletion fluent/test/constructor_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import assert from 'assert';
import sinon from 'sinon';

import { FluentBundle } from '../src/context';
import FluentBundle from '../src/context';
import { ftl } from '../src/util';

suite('FluentBundle constructor', function() {
Expand Down
21 changes: 20 additions & 1 deletion fluent/test/context_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import assert from 'assert';

import { FluentBundle } from '../src/context';
import FluentBundle from '../src/context';
import FluentResource from '../src/resource';
import { ftl } from '../src/util';

suite('Bundle', function() {
Expand Down Expand Up @@ -70,6 +71,24 @@ suite('Bundle', function() {
});
});

suite('addResource', function(){
suiteSetup(function() {
bundle = new FluentBundle('en-US', { useIsolating: false });
let resource = FluentResource.fromString(ftl`
foo = Foo
-bar = Bar
`);
bundle.addResource(resource);
});

test('adds messages', function() {
assert.equal(bundle._messages.has('foo'), true);
assert.equal(bundle._terms.has('foo'), false);
assert.equal(bundle._messages.has('-bar'), false);
assert.equal(bundle._terms.has('-bar'), true);
});
});

suite('hasMessage', function(){
suiteSetup(function() {
bundle = new FluentBundle('en-US', { useIsolating: false });
Expand Down
2 changes: 1 addition & 1 deletion fluent/test/functions_builtin_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import assert from 'assert';

import { FluentBundle } from '../src/context';
import FluentBundle from '../src/context';
import { ftl } from '../src/util';

suite('Built-in functions', function() {
Expand Down
2 changes: 1 addition & 1 deletion fluent/test/functions_runtime_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import assert from 'assert';

import { FluentBundle } from '../src/context';
import FluentBundle from '../src/context';
import { ftl } from '../src/util';

suite('Runtime-specific functions', function() {
Expand Down
2 changes: 1 addition & 1 deletion fluent/test/functions_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import assert from 'assert';

import { FluentBundle } from '../src/context';
import FluentBundle from '../src/context';
import { ftl } from '../src/util';

suite('Functions', function() {
Expand Down
2 changes: 1 addition & 1 deletion fluent/test/isolating_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import assert from 'assert';

import { FluentBundle } from '../src/context';
import FluentBundle from '../src/context';
import { ftl } from '../src/util';

// Unicode bidi isolation characters.
Expand Down
2 changes: 1 addition & 1 deletion fluent/test/patterns_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import assert from 'assert';

import { FluentBundle } from '../src/context';
import FluentBundle from '../src/context';
import { ftl } from '../src/util';

suite('Patterns', function(){
Expand Down
2 changes: 1 addition & 1 deletion fluent/test/primitives_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import assert from 'assert';

import { FluentBundle } from '../src/context';
import FluentBundle from '../src/context';
import { ftl } from '../src/util';

suite('Primitives', function() {
Expand Down
2 changes: 1 addition & 1 deletion fluent/test/select_expressions_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import assert from 'assert';

import { FluentBundle } from '../src/context';
import FluentBundle from '../src/context';
import { ftl } from '../src/util';

suite('Select expressions', function() {
Expand Down
2 changes: 1 addition & 1 deletion fluent/test/transform_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import assert from 'assert';

import { FluentBundle } from '../src/context';
import FluentBundle from '../src/context';
import { ftl } from '../src/util';

suite('Transformations', function(){
Expand Down
2 changes: 1 addition & 1 deletion fluent/test/values_format_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import assert from 'assert';

import { FluentBundle } from '../src/context';
import FluentBundle from '../src/context';
import { ftl } from '../src/util';

suite('Formatting values', function(){
Expand Down
2 changes: 1 addition & 1 deletion fluent/test/values_ref_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import assert from 'assert';

import { FluentBundle } from '../src/context';
import FluentBundle from '../src/context';
import { ftl } from '../src/util';

suite('Referencing values', function(){
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/benchmark.d8.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var resource = FluentSyntax.parse(ftlCode);
times.ftlParseEnd = Date.now();

times.ftlEntriesParseStart = Date.now();
var [entries] = Fluent._parse(ftlCode);
var resource = Fluent.FluentResource.fromString(ftlCode);
times.ftlEntriesParseEnd = Date.now();

var bundle = new Fluent.FluentBundle('en-US');
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/benchmark.jsshell.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var resource = FluentSyntax.parse(ftlCode);
times.ftlParseEnd = dateNow();

times.ftlEntriesParseStart = dateNow();
var [entries] = Fluent._parse(ftlCode);
var resource = Fluent.FluentResource.fromString(ftlCode);
times.ftlEntriesParseEnd = dateNow();

var bundle = new Fluent.FluentBundle('en-US');
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/benchmark.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var resource = FluentSyntax.parse(ftlCode);
cumulative.ftlParseEnd = process.hrtime(start);

cumulative.ftlEntriesParseStart = process.hrtime(start);
var [entries] = Fluent._parse(ftlCode);
var resource = Fluent.FluentResource.fromString(ftlCode);
cumulative.ftlEntriesParseEnd = process.hrtime(start);

var bundle = new Fluent.FluentBundle('en-US');
Expand Down