Réamhfhocail are difficult in the sense that dialects don't have a uniformed way of dealing with them-
sa bhaile/ sa mbaile, leis an mballa/ leis an bhalla...srl..
This goes back to old Irish where you had réamhfhocail that fell into cuspóireach, tabharthach and those that could be either e.g:
Modern Irish represented in brackets:
Cuspóireach/ tabharthach: ar (roimh), fo (fé/ faoi), for (ar), i (i/ sa)
Cuspóireach: amhal (mar), cen (gan), co (go/ chuige), eter (idir), fri (le/ ri),imm (um), la (le), sech (seachas), tar (trasna/ thar), tre (tré (mumhan), trí)
Tabharthach: a (as), co (le), di (de), do (do), íar (tar- éis), (s)ís (faoi- thíos, íseal, síos), ó (ó), ós (above/ thuas/ suas), oc (ag), rem/ren (roimh)
réamhfhocal + an t-alt SeanaGhaolainn:
Tabharthach + séimhiú - ón chat
Cuspóireach + urú- frisin mball
Thats why in dialects people say sa mbaile or sa bhaile- both are correct.
Modern day:
Some introduce the dative: e.g ar an gcait (GM) ar an gcat (GC).. ar an chat (GU)... ar an gcat (CO)
Some introduce the tuiseal ainmneach: go dtí (except in some parts of Munster where its in the dative/ tabharthach), seachas, gan srl...
Some réamhfhocal introduce the tuiseal ginideach like "chun", timpeall, trasna e.g chun an bhoird srl...
and some can introduce both like "roimh"/ roim (GM)/ Roim(h)is an (GM): roimh an gcathair/ roimh na cathrach srl...
Unfortunately, there is no formula in knowing how to know which goes where, just comes down to experience, practice and intuition of just knowing what seems right.
Most simple réamhfhocal follow the dative:
ag- no séimhiú after ag... ag + article- ag an gcat
ar- séimhiu (most of the time exc. ar bruach na habhann srl)... ar + article= urú, ar an mbord
as- no séimhiú... as + article= urú- as an mbróg
chuig-- no séimhiú... chuig + article= urú- chuig an mbord
de- seimhiú- de dhuine- de + article = seimhiú (Co) don chat... (GM) don gcat... you can't have two vowels together so you get do + an= do'n (older writing or don). You would think that it would follow the rule of ar an = urú, it instead follows the old Irish rule of tabharthach + Séimhiú
do- séimhiú - do dhuine- de + article= seimhiú den chat
faoi/ fé/ fá- séimhiú- faoi + article = urú- faoin gcat
i- urú- i nGaillimh, in vowels in Éirinn used to be written as i nÉirinn where the urú can be seen more clearly. i/ sa = san fharraige/ sa bhfarraige (GM) or ins an= ainmneach ins an Chathair.
idir- no séimhiú when it means among e.g idir mná (CO) (plural idir na + Dative)- idir + article= urú (in Munster not sure of CO!)
le- no seimhiú (exc.. le chéile)- le + article= leis an mballa/ bhfalla (C0, GM, GC)
ó- séimhiú- ó + article= urú- ón gcarr (CO, GC)
roimh/ roim- does and doesn't have a seimhiú depending on dialect (not sure what (CO) is)- roimh + article- roimh an gcarr (CO, GC) also tuiseal ginideach may be used
thar- séimhiú/ no seimhiú (depending on dialect). Thar + article= urú thar an ngeata (CO, GC, GM)
trí- séimhiú, trí + article= urú- trí
d an ngeata
um- seimhiú- um thrathnóna
In the article plural (tabharthach) the caighdeán does not introduce the older dative ending of aibh/ ibh) it just uses the ainmneach plural:
(sorry I haven'y the English for a lot of Irish terms)
so
ar na daoine
ag na páistí
My logic for why the older dative forms haven't survived in other Gaeltachats is because of their phonetics: so
ag na daoinibh (Munster Irish pronounce-ibh/ aibh like iv, whereas aibh everywhere else would be pronounced like í- hence daoiní- my opinion might be wrong but it looks plausible.
Reamhfhocail that introduce ainmneach in (CO)gan, go dtí, seachas- there is probably more just can't think of them off the top of my head right now
Réamhfhocal that introduce the Tuiseal Ginideach: Used when there is a réamhfhocal + an ainmfhocal the word proceeding it will be in its Tuiseal Ginideach e.g i (reamhfhocal) + rith (Ainmfhocal) na hoiche (Ginideach of an Oiche)
There is a hell of a lot of these- all the words for because/ for (except mar- mar gheall, mar an gcéanna), all to do with time- i rith, le linn, in aimsir, ) direction ( i lár na cathrach, ar chúl an tí
I hope this helped a bit, it seems very difficult from looking at this but with a little practice (not from learning grammitical Rules) but by reading and be aware why words change- thats the best way to learn in my opinion. I don't know everything and what I have given is only my own understandings, it may have flaws- i'd be grateful if any one would like to correct them
Now to make this load of shite fun and "real" lets have a game:
Críochnaigh na habairtí so a leannas:
Bhí an cat ar an____ (an bord)
Bhí an cailín dána i dteannta___ (na buachaillí)
Chaith mé an buidéal le___ (an ball)
Phrioc/ Phioc mé na prátaí le haghaidh___ (mo mháthair)
Cuirtear pionóis ar______ (na daltaí) chun smacht a choimeád orthu