# j-Resource

> Resources are very great solution for e.g. translate some texts in all scripts. The component can be appended multiple-times and all components use one repository for storing keys and values.

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: en
Content-SHA256: 7104cdd07cf4875e0833983d577a07667f8a8a5c3a8c9068d593c3671e4e02bc
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: components@910ed1a86f6e72b4f031d3ad0dc7844f9fc5cb8e
Review: not-recorded

Resources are very great solution for e.g. translate some texts in all scripts. The component can be appended multiple-times and all components use one repository for storing keys and values.


__METHODS__:

- `RESOURCE(key, [def])` - is a global method
- `FIND('resource').download('/my-dictionary.txt', [callback]);` - for importing new resources

Use it with `<ui-component name="resource">`. When the component is not loaded yet, jComponent downloads it on first use from the address in `DEF.fallback` (the Componentator CDN by default). Author: Peter Širka. Source: the Componentator components repository, MIT license.

```html example.html
Open Web Developer console.

<ui-component name="resource">
	<script type="text/plain">
			yes     : Yes
			no      : No
			message : Are you sure?
	</script>
</ui-component>

<ui-component name="resource">
	<script type="text/plain">
			first     : Value of first
			second    : Value of second
			a b c     : ABC
	</script>
</ui-component>

<script>

	setTimeout(function() {
		console.log(RESOURCE('yes'));
		console.log(RESOURCE('no'));
		console.log(RESOURCE('message'));
		console.log(RESOURCE('first'));
		console.log(RESOURCE('second'));
		console.log(RESOURCE('a b c'));
		console.log(RESOURCE('notfound', 'NOT FOUND'));
	}, 2000);

</script>
```
