# Is there a way to add to an array from multiple files?

**URL:** <https://www.ruby-forum.com/t/is-there-a-way-to-add-to-an-array-from-multiple-files/213432>\
**Category:** Rails I18n\
**Created:** [November 2, 2011, 12:18am UTC](https://www.ruby-forum.com/t/is-there-a-way-to-add-to-an-array-from-multiple-files/213432 "2011-11-02T00:18:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [November 2, 2011, 12:18am UTC](https://www.ruby-forum.com/t/is-there-a-way-to-add-to-an-array-from-multiple-files/213432/1 "2011-11-02T00:18:45Z")

</div>

say I have:  
locales/file1.yml

en:  
foo:  
- bar

locales/file2.yml  
en:  
foo:  
- baz

I want to be able to call t(“foo”) and get [“bar”, “baz”]… Is there  
any way to do this?

-patrick

---

<div class="post-metadata">

**Author:** ![patrick99e99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/858c86/32.png) [@patrick99e99](https://www.ruby-forum.com/u/patrick99e99)\
**Post date:** [November 2, 2011, 6:10am UTC](https://www.ruby-forum.com/t/is-there-a-way-to-add-to-an-array-from-multiple-files/213432/2 "2011-11-02T06:10:27Z")

</div>

Yaml returns string only. So, I guess what you can do use

foo:  
‘bar baz’

and then f(‘foo’).split(’ ')

it’s hack, but i don’t see other option.

On Wed, Nov 2, 2011 at 4:47 AM, patrick99e99 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ```
> - baz
> 
> ```
> 
> To unsubscribe from this group, send email to  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid).  
> For more options, visit this group at  
> [http://groups.google.com/group/rails-i18n?hl=en](http://groups.google.com/group/rails-i18n?hl=en).

–  
Ratnadeep Deshmane.  
[http://rtdptech.com](http://rtdptech.com)

---

<div class="post-metadata">

**Author:** ![patrick99e99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/858c86/32.png) [@patrick99e99](https://www.ruby-forum.com/u/patrick99e99)\
**Post date:** [November 2, 2011, 10:14am UTC](https://www.ruby-forum.com/t/is-there-a-way-to-add-to-an-array-from-multiple-files/213432/3 "2011-11-02T10:14:17Z")

</div>

This should do it :

foo:

- bar
- baz

You can’t keep each array entry in a separate file because you’ll  
redefine the whole ‘foo’ scope every time.
